From 993b434093c7daf376187ef2fc8ccad8ad47f0c4 Mon Sep 17 00:00:00 2001 From: Iori Yanokura Date: Wed, 19 Mar 2025 22:52:14 +0900 Subject: [PATCH] ENH: Migrate CI to use cibuildwheel for building wheels --- .github/workflows/ci.yaml | 62 ++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 223cd4d..ee384f5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -51,10 +51,13 @@ jobs: pip install pytest pytest - build-for-publish: + build-wheels-for-publish: name: Build distribution 📦 - runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags')" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, ubuntu-latest-arm, windows-latest, macos-latest] needs: test steps: - uses: actions/checkout@v4 @@ -68,16 +71,46 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade build + python -m pip install cibuildwheel==2.16.2 - - name: Build a source tarball and wheel - run: python -m build . + - name: Build wheels + env: + CIBW_SKIP: "pp* *-musllinux_*" + run: python -m cibuildwheel --output-dir wheelhouse - name: Store the distribution packages uses: actions/upload-artifact@v4 with: - name: python-package-distributions - # NOTE: for now upload sdist only to prevent errors like unsupported platform tag 'linux_x86_64'. + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + build-sdist-for-publish: + name: Build source distribution 📦 + if: "startsWith(github.ref, 'refs/tags')" + runs-on: ubuntu-latest + needs: test + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: true + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e ".[dev]" + - name: Install build tool + run: python -m pip install sdist + - name: Build source distribution + run: python setup.py sdist + - name: Upload sdist artifact + uses: actions/upload-artifact@v4 + with: + name: sdist-artifact path: dist/*.tar.gz publish-to-pypi: @@ -85,7 +118,8 @@ jobs: Publish Python 🐍 distribution 📦 to PyPI if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes needs: - - build-for-publish + - build-wheels-for-publish + - build-sdist-for-publish runs-on: ubuntu-latest environment: name: pypi @@ -96,12 +130,20 @@ jobs: - name: Download all the dists uses: actions/download-artifact@v4 with: - name: python-package-distributions - path: dist/ + # unpacks all CIBW artifacts into dist/ + path: dist + pattern: cibw-wheels-* + merge-multiple: true + - name: Download sdist artifact + uses: actions/download-artifact@v4 + with: + name: sdist-artifact + path: dist - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: verbose: true + password: ${{ secrets.PYPI_TOKEN }} # NOTE: for testing purposes only # publish-to-testpypi: