Remove "Build macos-12 wheels" since macos-12 label and runners are n… #97
This file contains 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
# Build, test, and upload to PyPI | |
name: Publish | |
on: | |
workflow_dispatch: | |
push: | |
# The workflow is triggered if either of the 2 conditions below is satisfied | |
branches: [ "main" ] | |
tags: ['v*'] # Push events to matching v*, i.e. v1.0, v20.15.10 | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
# macos-13 uses intel runner, macos-14 is apple silicon, no runners for macos-14 with intel x86-64 | |
os: [ubuntu-22.04, macos-13, macos-14, windows-2019, windows-2022] | |
# Uncomment the following line for faster testing of the workflow | |
# os: [ubuntu-22.04] | |
steps: | |
- name: Checkout the repository to the GitHub runner | |
uses: actions/checkout@v4 | |
- name: Setup GNU Fortran | |
if: false == contains( matrix.os, 'windows') | |
uses: awvwgk/setup-fortran@v1 | |
- name: Install mingw-w64 as Fortran compiler on Windows | |
if: contains( matrix.os, 'windows') | |
uses: msys2/setup-msys2@v2 | |
with: | |
path-type: inherit | |
install: | | |
mingw-w64-x86_64-gcc | |
mingw-w64-x86_64-gcc-fortran | |
# - name: Install rtools (mingw-w64) on Windows | |
# if: contains( matrix.os, 'windows') | |
# run: | | |
# choco install rtools -y --no-progress --force --version=4.0.0.20220206 | |
# echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH | |
- name: Build macos-13 wheels | |
if: contains( matrix.os, 'macos-13') | |
uses: pypa/cibuildwheel@v2.18.1 | |
env: | |
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET="13.0" | |
- name: Build macos-14 wheels | |
if: contains( matrix.os, 'macos-14') | |
uses: pypa/cibuildwheel@v2.18.1 | |
env: | |
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET="14.0" | |
# Warning: While cibuildwheel can build CPython 3.8 universal2/arm64 wheels, | |
# we cannot test the arm64 part of them, even when running on an Apple Silicon machine. | |
# This is because we use the x86_64 installer of CPython 3.8. | |
# See the discussion in https://github.com/pypa/cibuildwheel/pull/1169 for the details. | |
# To silence this warning: set `CIBW_TEST_SKIP: "cp38-macosx_*:arm64"` | |
CIBW_TEST_SKIP: "cp38-macosx_arm64" | |
- name: Build linux wheels | |
if: contains( matrix.os, 'ubuntu') | |
uses: pypa/cibuildwheel@v2.18.1 | |
# Uncomment the following 2 lines for faster testing of the workflow | |
# env: | |
# CIBW_BUILD: "cp38-* cp312-*" | |
- name: Build Windows wheels # only for python>=3.9 | |
if: contains( matrix.os, 'windows') | |
uses: pypa/cibuildwheel@v2.18.1 | |
# env: | |
# CIBW_SKIP: "cp38-* *-win32" # win32 needs to be specified since this overrides skip specified in pyproject.toml | |
# # Now handled in pyproject.toml windows subsection | |
- uses: actions/upload-artifact@v4 | |
with: | |
# Name of the artifact to upload. | |
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
# A file, directory or wildcard pattern that describes what to upload. Required. | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
name: Build source distribution | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build sdist | |
# run: pipx run build --sdist | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install build | |
python -m build --sdist --outdir dist/ | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-sdist | |
path: ./dist/*.tar.gz | |
# sdists are not tested by cibuildwheel so we test them manually for v* tags | |
# We only run a limited number of configurations here to save actions minutes | |
manual_test_of_sdist: | |
name: Manual test of sdist | |
needs: [build_sdist] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04, macos-13, macos-14, windows-2019, windows-2022] | |
python-version: ["3.9", "3.12"] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Setup GNU Fortran | |
if: false == contains( matrix.os, 'windows') | |
uses: awvwgk/setup-fortran@v1 | |
- name: Install mingw-w64 as Fortran compiler on Windows | |
if: contains( matrix.os, 'windows') | |
uses: msys2/setup-msys2@v2 | |
with: | |
path-type: inherit | |
install: | | |
mingw-w64-x86_64-gcc | |
mingw-w64-x86_64-gcc-fortran | |
# - name: Install rtools (mingw-w64) on Windows | |
# if: contains( matrix.os, 'windows') | |
# run: | | |
# choco install rtools -y --no-progress --force --version=4.0.0.20220206 | |
# echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH | |
- name: Checkout the repository to the GitHub runner | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
update-environment: true | |
- uses: actions/download-artifact@v4 | |
with: | |
name: cibw-sdist | |
# destination path | |
path: dist | |
- name: Install the sdist | |
run: | | |
python -m pip install --upgrade pip | |
# python -m pip install ./dist/*.tar.gz # This wildcard expansion does not work on Windows | |
# Use Python’s glob module to explicitly handle the wildcard in a platform-independent way: | |
python -m pip install $(python -c "import glob; print(glob.glob('./dist/*.tar.gz')[0])") | |
python -m pip install pytest | |
- name: Run tests | |
run: | | |
pytest | |
# Upload built wheels and sdist to PyPI. Runs only when a v* tag is pushed. | |
upload_pypi: | |
name: Upload to PyPI | |
needs: [build_wheels, build_sdist, manual_test_of_sdist] | |
runs-on: ubuntu-22.04 | |
# environment: testpypi | |
environment: pypi | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/download-artifact@v4 | |
# unpacks all CIBW artifacts into dist/ | |
with: | |
# A glob pattern to the artifacts that should be downloaded. | |
# If unspecified, all artifacts for the run are downloaded. | |
pattern: cibw-* | |
# destination path | |
path: dist | |
# If true, the downloaded artifacts will be in the same directory specified by path. | |
# If false, the downloaded artifacts will be extracted into individual named directories within the specified path. | |
merge-multiple: true | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
# with: | |
# repository-url: https://test.pypi.org/legacy/ |