From 72e3b495ab776b5ba524217099ed7a2c88cbd909 Mon Sep 17 00:00:00 2001 From: Keming Date: Mon, 20 Jan 2025 22:56:42 +0800 Subject: [PATCH] fix(ci): release on ubuntu with wheels from previous steps (#1960) * fix: release on ubuntu:24.04 with gh-action-pypi-publish Signed-off-by: Keming * test ghcr Signed-off-by: Keming --------- Signed-off-by: Keming --- .github/workflows/release.yml | 114 +++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e9ab3606c..38db5ebd6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,10 @@ name: release on: release: types: [published] + workflow_dispatch: jobs: goreleaser: - if: github.repository == 'tensorchord/envd' runs-on: ubuntu-latest steps: - name: Checkout @@ -17,7 +17,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: 'stable' - - name: Docker Login + - name: Login to Docker uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERIO_USERNAME }} @@ -39,56 +39,72 @@ jobs: dist/envd_linux_amd64_v1/envd dist/envd_darwin_all/envd if-no-files-found: error - pypi_publish: + python_build: needs: goreleaser - # only trigger on main repo when tag starts with v - if: github.repository == 'tensorchord/envd' && startsWith(github.ref, 'refs/tags/v') runs-on: ${{ matrix.os }} - timeout-minutes: 20 - permissions: - id-token: write # IMPORTANT: this permission is mandatory for trusted publishing strategy: matrix: os: [macos-13, ubuntu-22.04] steps: - - uses: actions/checkout@v4 - - name: Get gobin - uses: actions/download-artifact@v4 - with: - name: gobin_${{ github.event.release.tag_name }} - path: dist/ - - name: Configure linux build environment - if: runner.os == 'Linux' - run: | - mkdir -p bin - mv dist/envd_linux_amd64_v1/envd bin/envd - chmod +x bin/envd - - name: Configure macOS build environment - if: runner.os == 'macOS' - run: | - mkdir -p bin - mv dist/envd_darwin_all/envd bin/envd - chmod +x bin/envd - - name: setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - name: Build wheels - uses: pypa/cibuildwheel@v2.22.0 - env: - CIBW_ARCHS_MACOS: arm64, x86_64 - CIBW_ARCHS_LINUX: auto64 - CIBW_SKIP: pp* - - name: Build source distribution - if: runner.os == 'Linux' # Only release source under linux to avoid conflict - run: | - python -m pip install wheel - python setup.py sdist - mv dist/*.tar.gz wheelhouse/ - - name: Publish package distributions to PyPI - run: | - python -m pip install twine - python -m twine upload --skip-existing wheelhouse/* + - uses: actions/checkout@v4 + - name: Get gobin + uses: actions/download-artifact@v4 + with: + name: gobin_${{ github.event.release.tag_name }} + path: dist/ + - name: Configure linux build environment + if: runner.os == 'Linux' + run: | + mkdir -p bin + mv dist/envd_linux_amd64_v1/envd bin/envd + chmod +x bin/envd + - name: Configure macOS build environment + if: runner.os == 'macOS' + run: | + mkdir -p bin + mv dist/envd_darwin_all/envd bin/envd + chmod +x bin/envd + - name: setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Build wheels + uses: pypa/cibuildwheel@v2.22.0 + env: + CIBW_ARCHS_MACOS: arm64, x86_64 + CIBW_ARCHS_LINUX: auto64 + CIBW_SKIP: pp* + - name: Build source distribution + if: runner.os == 'Linux' # Only release source under linux to avoid conflict + run: | + python -m pip install wheel + python setup.py sdist + mv dist/*.tar.gz wheelhouse/ + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: pypi_${{ github.event.release.tag_name }}_${{ matrix.os }} + path: wheelhouse/ + retention-days: 1 + pypi_publish: + needs: python_build + # only trigger on main repo when tag starts with v + if: github.repository == 'tensorchord/envd' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-24.04 + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + pattern: pypi_${{ github.event.release.tag_name }}_* + merge-multiple: true + path: dist/ + - name: Upload to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip-existing: true + verbose: true image_publish: name: Build & push images # only trigger on main repo when tag starts with v @@ -118,6 +134,8 @@ jobs: envd_starship_publish: name: Push starship image to Docker Hub runs-on: ubuntu-latest + # only trigger on main repo when tag starts with v + if: github.repository == 'tensorchord/envd' && startsWith(github.ref, 'refs/tags/v') needs: goreleaser steps: - uses: actions/checkout@v4 @@ -177,10 +195,6 @@ jobs: tag_suffix: "" - build_func: build_gpu_11_6 tag_suffix: "-cuda-11.6.2-cudnn-8" - - build_func: build_gpu_11_8 - tag_suffix: "-cuda-11.8.0-cudnn-8" - - build_func: build_gpu_12_3 - tag_suffix: "-cuda-12.3.2-cudnn-9" needs: image_publish steps: - uses: actions/checkout@v4