From a9ad89e251a6a0a18fccfa2db5ec62f83a8069f6 Mon Sep 17 00:00:00 2001 From: Ash Vardanian <1983160+ashvardanian@users.noreply.github.com> Date: Wed, 21 Feb 2024 20:26:50 +0000 Subject: [PATCH] Make: Parallel CI for Python wheels --- .github/workflows/prerelease.yml | 27 +++++++++++++++++ .github/workflows/release.yml | 50 ++++++++++++++++---------------- 2 files changed, 52 insertions(+), 25 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 23f728d8..b449a1c6 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -302,3 +302,30 @@ jobs: context: . load: true push: false + + + build_wheels: + name: Build Python ${{ matrix.python-version }} for ${{ matrix.os }} + runs-on: ${{ matrix.os }} + needs: [test_ubuntu_gcc, test_ubuntu_clang, test_macos, test_windows] + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["37", "38", "39", "310", "311", "312"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.x + + # We only need QEMU for Linux builds + - name: Setup QEMU + if: matrix.os == 'ubuntu-latest' + uses: docker/setup-qemu-action@v3 + - name: Install cibuildwheel + run: python -m pip install cibuildwheel + - name: Build wheels + run: cibuildwheel --output-dir wheelhouse + env: + CIBW_BUILD: cp${{ matrix.python-version }}-* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8d22c460..78f8e2d9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -346,39 +346,36 @@ jobs: * ${{ steps.hashes.outputs.asset_name_15 }} : `${{ steps.hashes.outputs.asset_hash_15 }}` build_wheels: - name: Build Python - needs: versioning + name: Build Python ${{ matrix.python-version }} for ${{ matrix.os }} runs-on: ${{ matrix.os }} + needs: versioning strategy: - fail-fast: false matrix: - os: [ubuntu-22.04, macOS-11, windows-2022] - + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["37", "38", "39", "310", "311", "312"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: "main" - - uses: actions/setup-python@v3 - - - name: Setup Docker - if: matrix.os == 'ubuntu-22.04' - uses: crazy-max/ghaction-setup-docker@v1.0.0 + - name: Set up Python + uses: actions/setup-python@v5 with: - version: 23.0.1 - + python-version: 3.x - name: Setup QEMU - if: matrix.os == 'ubuntu-22.04' - uses: docker/setup-qemu-action@v2.1.0 - - - name: Install CIBuildWheel + if: matrix.os == 'ubuntu-latest' # We only need QEMU for Linux builds + uses: docker/setup-qemu-action@v3 + - name: Install cibuildwheel run: python -m pip install cibuildwheel - - name: Build wheels - run: python -m cibuildwheel - - - uses: actions/upload-artifact@v3 + run: cibuildwheel --output-dir wheelhouse + env: + CIBW_BUILD: cp${{ matrix.python-version }}-* + - name: Upload wheels + uses: actions/upload-artifact@v4 with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} path: ./wheelhouse/*.whl + overwrite: true publish_python: name: Publish Python @@ -392,17 +389,20 @@ jobs: steps: - name: Download artifacts - uses: actions/download-artifact@v3.0.2 + uses: actions/download-artifact@v4 with: - path: ./dist/ + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true - name: Publish to PyPi uses: pypa/gh-action-pypi-publish@release/v1 with: - packages-dir: ./dist/artifact + packages-dir: dist verbose: true print-hash: true - + publish_javascript: name: Publish JavaScript needs: versioning