Skip to content

Commit

Permalink
add build wheel workflow
Browse files Browse the repository at this point in the history
Signed-off-by: yuchen.cc <[email protected]>
  • Loading branch information
yuchen0cc authored and liulanzheng committed Aug 28, 2024
1 parent bbf5fc5 commit ac06d28
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/build_wheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build Wheel

on:
push:
tags:
- "v*"

jobs:
build:
name: "Build Release"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup buildx instance
uses: docker/setup-buildx-action@v2
with:
use: true
- name: Build
shell: bash
run: |
RELEASE_VERSION=${{ github.ref }}
RELEASE_VERSION="${RELEASE_VERSION#refs/tags/v}"
echo "RELEASE_VERSION=${RELEASE_VERSION}"
PYTHON_VERSION=${{ matrix.python }}
PYTHON_VERSION=${PYTHON_VERSION//./}
echo "PYTHON_VERSION=${PYTHON_VERSION}"
BUILD_IMAGE="ghcr.io/${GITHUB_REPOSITORY,,}/connector_builder:base"
echo "BUILD_IMAGE=${BUILD_IMAGE}"
RELEASE_IMAGE="ghcr.io/${GITHUB_REPOSITORY,,}/connector_builder:${RELEASE_VERSION}"
echo "RELEASE_IMAGE=${RELEASE_IMAGE}"
docker buildx build --build-arg BUILD_IMAGE=${BUILD_IMAGE} --build-arg RELEASE_IMAGE=${RELEASE_IMAGE} --build-arg PYTHON_VERSION=${PYTHON_VERSION} -f .github/workflows/build_wheel/Dockerfile -o dist/ .
ls -l dist/
- name: Upload
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/osstorchconnector*

release:
name: "Tagged Release"
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Download builds and release notes
uses: actions/download-artifact@v3
- name: Display downloaded files
shell: bash
run: |
ls -l dist
releasever=${{ github.ref }}
releasever="${releasever#refs/tags/}"
echo "RELEASE_VERSION=${releasever}" >> $GITHUB_ENV
- name: Create Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
prerelease: false
files: dist/osstorchconnector*
18 changes: 18 additions & 0 deletions .github/workflows/build_wheel/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG RELEASE_IMAGE
ARG BUILD_IMAGE
FROM ${RELEASE_IMAGE} AS release

FROM ${BUILD_IMAGE} AS builder
WORKDIR /libosstorchconnector
COPY --from=release /libosstorchconnector .
COPY . .
ARG PYTHON_VERSION
ENV PY_VER=${PYTHON_VERSION}
RUN source /root/miniconda3/etc/profile.d/conda.sh && \
export PATH="/root/miniconda3/bin:$PATH" && \
conda activate py${PY_VER} && \
echo -e "[build_ext]\nlibrary_path=oss_connector.cpython-${PY_VER}-x86_64-linux-gnu.so" > setup.cfg && \
python3 -u setup.py bdist_wheel

FROM scratch
COPY --from=builder /libosstorchconnector/dist/osstorchconnector* /

0 comments on commit ac06d28

Please sign in to comment.