name: Build and upload to PyPI on: release: types: [published] workflow_dispatch: jobs: build_wheels: name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-24.04, ubuntu-24.04-arm, windows-latest, macos-latest] steps: - uses: actions/checkout@v7 - uses: actions/setup-python@v7 - name: Build wheels # For very recent Python versions, wheels from e.g. numpy might not be # available yet which can cause the build to fail. Keep going, and upload # the wheels for all of the previous versions when that happens. continue-on-error: true uses: pypa/cibuildwheel@v4.2.0 - uses: actions/upload-artifact@v7 with: name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} path: ./wheelhouse/*.whl build_sdist: name: Build source distribution runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v7 - uses: actions/setup-python@v7 - name: Install build run: python -m pip install build - name: Build sdist run: python -m build --sdist - uses: actions/upload-artifact@v7 with: name: cibw-sdist path: dist/*.tar.gz upload_pypi: name: Upload to PyPI needs: [build_wheels, build_sdist] runs-on: ubuntu-24.04 permissions: id-token: write if: startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/download-artifact@v8 with: pattern: cibw-* path: dist merge-multiple: true - uses: pypa/gh-action-pypi-publish@release/v1