Add pip-installable wheels for Linux and macOS #3
Workflow file for this run
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 Python wheels | |
| on: | |
| push: | |
| branches: | |
| - "master" | |
| tags: | |
| - "v*" | |
| pull_request: | |
| branches: [ "master" ] | |
| release: | |
| types: [ published ] | |
| workflow_dispatch: | |
| concurrency: | |
| group: wheels-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| build-wheels: | |
| name: Wheels (${{ matrix.arch }} on ${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| arch: x86_64 | |
| - os: ubuntu-24.04-arm | |
| arch: aarch64 | |
| # macos_target must match the macOS version the runner's Homebrew | |
| # bottles were built for. delocate refuses to repair a wheel whose | |
| # vendored dylibs require a newer macOS than the wheel tag claims. | |
| # Revisit whenever these runner images change. | |
| - os: macos-14 | |
| arch: arm64 | |
| macos_target: "14.0" | |
| - os: macos-13 | |
| arch: x86_64 | |
| macos_target: "13.0" | |
| steps: | |
| # No `lfs: true` here: wheels are built from source only, and the LFS | |
| # fixtures are ~60 MB that no wheel job reads. | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v4.1.1 | |
| env: | |
| CIBW_ARCHS: ${{ matrix.arch }} | |
| MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos_target }} | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: wheels-${{ matrix.os }}-${{ matrix.arch }} | |
| path: ./wheelhouse/*.whl | |
| build-sdist: | |
| name: Source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Build sdist | |
| run: pipx run build --sdist | |
| - name: Install NetCDF (to compile the sdist) | |
| run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y --no-install-recommends \ | |
| build-essential cmake libnetcdf-dev libnetcdf-c++4-dev | |
| # Building the sdist end to end is the only check that someone on an | |
| # unsupported platform can still `pip install forefire`. | |
| - name: Install and smoke test the sdist | |
| run: | | |
| pip install dist/*.tar.gz | |
| python tests/python/test_wheel.py | |
| forefire -v | |
| - name: Upload sdist | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: sdist | |
| path: dist/*.tar.gz | |
| publish: | |
| name: Publish to PyPI | |
| needs: [ build-wheels, build-sdist ] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/forefire | |
| # Trusted publishing: no API token to rotate, but the `forefire` PyPI | |
| # project must first declare this repository and workflow as a trusted | |
| # publisher (https://docs.pypi.org/trusted-publishers/). | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Publish | |
| uses: pypa/gh-action-pypi-publish@v1.14.1 |