Build and publish wheels #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and publish wheels | |
| on: | |
| release: | |
| types: [published] | |
| # Allow manual trigger for testing | |
| workflow_dispatch: | |
| jobs: | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pypa/cibuildwheel@v2.22 | |
| env: | |
| # Build for Python 3.10, 3.11, 3.12 | |
| CIBW_BUILD: "cp310-* cp311-* cp312-*" | |
| # Skip 32-bit builds and musl linux | |
| CIBW_SKIP: "*-manylinux_i686 *-musllinux*" | |
| # macOS: build both Intel and Apple Silicon | |
| CIBW_ARCHS_MACOS: "x86_64 arm64" | |
| CIBW_ARCHS_LINUX: "x86_64" | |
| # Build dependencies (pybind11 is needed at compile time) | |
| CIBW_BUILD_FRONTEND: "pip" | |
| # Test the built wheel | |
| CIBW_TEST_COMMAND: "python -c \"import SpatialQueryEliasFanoDB; print('C++ extension OK')\"" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }} | |
| path: ./wheelhouse/*.whl | |
| build_sdist: | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - run: pip install build | |
| - run: python -m build --sdist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist/*.tar.gz | |
| publish: | |
| name: Publish to PyPI | |
| needs: [build_wheels, build_sdist] | |
| runs-on: ubuntu-latest | |
| # Only publish on release events | |
| if: github.event_name == 'release' | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/SpatialQuery | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: dist/ | |
| merge-multiple: true | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |