Build wheels and upload to PyPI #203
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 wheels and upload to PyPI | |
| on: | |
| workflow_dispatch: | |
| release: | |
| types: | |
| - published | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-14, macos-15-intel] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: macOS - Set up Fortran | |
| if: runner.os == 'macOS' | |
| uses: fortran-lang/setup-fortran@v1 | |
| with: | |
| version: 14 | |
| - name: macOS - Set deployment target | |
| if: runner.os == 'macOS' | |
| run: | | |
| echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d '.' -f 1-2)" >> $GITHUB_ENV | |
| # This does not work inside CIBW_BEFORE_ALL_MACOS; Without it, the wheel repair fails. | |
| - name: Windows - Set up pkg-config | |
| if: runner.os == 'windows' | |
| shell: bash | |
| run: | | |
| choco install -y --no-progress --stoponfirstfailure pkgconfiglite | |
| echo "PKG_CONFIG_PATH=C:/mingw64/lib/pkgconfig" >> $GITHUB_ENV | |
| # echo "C:/msys64/mingw64/bin" >> $GITHUB_PATH | |
| - name: Build cp310/cp311 wheels | |
| uses: pypa/cibuildwheel@v3.3.1 | |
| env: | |
| # All cibuildwheel options are here (nothing "hidden" in pyproject.toml) | |
| CIBW_BUILD: "cp310-* cp311-*" | |
| CIBW_SKIP: "*-win32 *i686" | |
| CIBW_BUILD_FRONTEND: build | |
| CIBW_BUILD_VERBOSITY: 3 | |
| CIBW_TEST_REQUIRES: pytest scipy | |
| CIBW_TEST_COMMAND: | | |
| pytest {project}/tests | |
| CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64 | |
| CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_2 | |
| CIBW_BEFORE_ALL_LINUX: | | |
| bash {project}/cibw-scripts/before_all_linux.sh {project} | |
| CIBW_BEFORE_ALL_WINDOWS: | | |
| bash {project}/cibw-scripts/before_all_windows.sh | |
| CIBW_BEFORE_BUILD_WINDOWS: | | |
| pip install delvewheel | |
| CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: | | |
| bash ./cibw-scripts/repair_wheel_command_windows.sh {wheel} {dest_dir} | |
| - name: Build cp312 abi3 wheels | |
| uses: pypa/cibuildwheel@v3.3.1 | |
| env: | |
| CIBW_BUILD: "cp312-*" | |
| CIBW_SKIP: "*-win32 *i686" | |
| CIBW_BUILD_FRONTEND: build | |
| # meson-python uses this to set the wheel ABI tag to abi3. | |
| CIBW_CONFIG_SETTINGS: "tool.meson-python.limited-api=true" | |
| CIBW_BUILD_VERBOSITY: 3 | |
| CIBW_TEST_REQUIRES: pytest scipy | |
| CIBW_TEST_COMMAND: | | |
| pytest {project}/tests | |
| CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64 | |
| CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_2 | |
| CIBW_BEFORE_ALL_LINUX: | | |
| bash {project}/cibw-scripts/before_all_linux.sh {project} | |
| CIBW_BEFORE_ALL_WINDOWS: | | |
| bash {project}/cibw-scripts/before_all_windows.sh | |
| CIBW_BEFORE_BUILD_WINDOWS: | | |
| pip install delvewheel | |
| CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: | | |
| bash ./cibw-scripts/repair_wheel_command_windows.sh {wheel} {dest_dir} | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
| path: ./wheelhouse/*.whl | |
| build_sdist: | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Build sdist | |
| run: pipx run build --sdist | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cibw-sdist | |
| path: dist/*.tar.gz | |
| upload_pypi: | |
| name: Publish to PyPI | |
| needs: [build_wheels, build_sdist] | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| permissions: | |
| id-token: write | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: cibw-* | |
| path: dist | |
| merge-multiple: true | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| # upload_test_pypi: | |
| # name: Publish to TestPyPI | |
| # needs: [build_wheels, build_sdist] | |
| # runs-on: ubuntu-latest | |
| # environment: | |
| # name: testpypi | |
| # url: https://test.pypi.org/p/odrpack | |
| # permissions: | |
| # id-token: write | |
| # if: ${{ github.event_name == 'workflow_dispatch' }} | |
| # steps: | |
| # - uses: actions/download-artifact@v4 | |
| # with: | |
| # pattern: cibw-* | |
| # path: dist | |
| # merge-multiple: true | |
| # - uses: pypa/gh-action-pypi-publish@release/v1 | |
| # with: | |
| # repository-url: https://test.pypi.org/legacy/ |