CI: Update workflow concurrency #64
Workflow file for this run
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
name: Build wheels | |
# Only build on tagged releases | |
on: | |
release: | |
types: [published] | |
# Also allow running this action on PRs if requested by applying the | |
# "Run cibuildwheel" label. | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- labeled | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event_name }}-${{ github.event.ref }} | |
cancel-in-progress: true | |
jobs: | |
build_wheels: | |
if: | | |
github.event_name == 'release' || | |
(github.event_name == 'pull_request' && ( | |
( | |
github.event.action == 'labeled' && | |
github.event.label.name == 'CI: build wheels' | |
) || | |
contains(github.event.pull_request.labels.*.name, | |
'CI: build wheels') | |
) | |
) | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-13, macos-14] | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v4 | |
# Used to host cibuildwheel | |
- uses: actions/setup-python@v3 | |
- name: Download source files | |
run: | | |
python .github/workflows/download_mirror.py | |
- name: Set up QEMU | |
if: runner.os == 'Linux' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
# sets up the compiler paths automatically for us | |
- uses: fortran-lang/setup-fortran@v1 | |
id: setup-fortran | |
with: | |
compiler: gcc | |
version: 13 | |
- name: Compiler versions | |
run: | | |
which gcc | |
gcc --version | |
which gfortran | |
gfortran --version | |
# On Windows, the compilers can cause issues when | |
# using higher optimization levels | |
- name: Add Windows environment settings | |
if: runner.os == 'Windows' | |
run: | | |
echo "FFLAGS=-O1" >> $GITHUB_ENV | |
# Windows can't decode the README which has utf8 characters | |
echo "PYTHONUTF8=1" >> $GITHUB_ENV | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v2.17.0 | |
env: | |
CIBW_BUILD: "cp310-* cp311-* cp312-*" | |
# skip 32 bit windows and linux builds because numpy | |
# does not provide wheels for these platforms | |
CIBW_SKIP: "*-win32 *_i686" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
name: Build source distribution | |
needs: build_wheels | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
name: Install Python | |
with: | |
python-version: '3.12' | |
- name: Download source files | |
run: | | |
python .github/workflows/download_mirror.py | |
- name: Build sdist | |
run: | | |
python -m pip install meson-python meson ninja build | |
python -m build --sdist | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: cibw-sdist | |
path: dist/*.tar.gz | |
upload_pypi: | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/project/pymsis | |
permissions: | |
id-token: write | |
# alternatively, to publish when a GitHub Release is created, use the following rule: | |
if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- name: Download sdist and wheels | |
uses: actions/download-artifact@v4 | |
with: | |
# unpacks all CIBW artifacts into dist/ | |
pattern: 'cibw-*' | |
path: dist | |
merge-multiple: true | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |