Merge pull request #392 from mabruzzo/badges #39
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
# inspired by | |
# - https://learn.scientific-python.org/development/guides/gha-wheels/ | |
# - https://cibuildwheel.pypa.io/en/stable/setup/#github-actions | |
# - https://github.com/yt-project/yt/blob/main/.github/workflows/wheels.yaml | |
# | |
# the numpy action that does the exact same thing | |
# https://github.com/numpy/numpy/blob/main/.github/workflows/wheels.yml | |
# illustrates a nifty trick for configuring the action to run whenever a commit | |
# is pushed where the commit-message is prefixed with [wheel build] | |
name: Wheel | |
on: | |
schedule: | |
# ┌───────────── minute (0 - 59) | |
# │ ┌───────────── hour (0 - 23) | |
# │ │ ┌───────────── day of the month (1 - 31) | |
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) | |
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) | |
# │ │ │ │ │ | |
- cron: "17 0 * * MON" | |
push: | |
branches: | |
- main | |
tags: | |
- 'grackle-*' | |
pull_request: | |
paths: | |
- '.github/workflows/wheels.yaml' | |
workflow_dispatch: | |
jobs: | |
make_sdist: | |
name: Make SDist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
# fetch the full git history to let us run all our tests | |
fetch-depth: 0 | |
# fetch the submodules to let us run the tests | |
submodules: true | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Build SDist | |
run: pipx run build --sdist | |
- name: Check README rendering for PyPI | |
run: | | |
python -mpip install twine | |
twine check dist/* | |
- name: Test sdist | |
run: | | |
sudo apt-get install libhdf5-dev | |
# it may not be necessary to setup a venv | |
python -m venv my-venv | |
source my-venv/bin/activate | |
pip install --upgrade pip | |
python -m pip install --group test "$(echo dist/*.tar.gz)" | |
python -m pip list | |
pytest | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-sdist | |
path: dist/*.tar.gz | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false # don't exit abruptly if another wheel can't be built | |
matrix: | |
os: [ | |
ubuntu-latest, | |
# we should revisit arm-based builds in the future | |
# -> the tests run REALLY slowly because wheels aren't shipped by yt/matplotlib | |
#ubuntu-24.04-arm, | |
macos-13, # (runs on intel-CPUs) | |
macos-14 #(runs on arm cpus) | |
] | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
# fetch the full git history to let us run all our tests | |
fetch-depth: 0 | |
# fetch the submodules to let us run the tests | |
submodules: true | |
- name: Set MACOSX_DEPLOYMENT_TARGET | |
if: startsWith( matrix.os, 'macos-' ) | |
run: | | |
# we may be able to reduce the following version numbers (or pick | |
# something consistent b/t Intel & Arm) once all fortran code is | |
# removed | |
RUNNER=${{ matrix.OS }} | |
if [ "$RUNNER" = "macos-14" ]; then # ARM-builds | |
echo "CIBW_ENVIRONMENT=MACOSX_DEPLOYMENT_TARGET=12.3" >> "$GITHUB_ENV" | |
elif [ "$RUNNER" = "macos-13" ]; then # Intel-builds | |
echo "CIBW_ENVIRONMENT=MACOSX_DEPLOYMENT_TARGET=10.14" >> "$GITHUB_ENV" | |
fi | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v3.1.4 | |
with: | |
output-dir: dist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
path: ./dist/*.whl | |
upload_all: | |
name: Publish to PyPI | |
needs: [build_wheels, make_sdist] | |
environment: pypi | |
permissions: | |
id-token: write | |
attestations: write | |
contents: read | |
runs-on: ubuntu-latest | |
# upload to PyPI on every tag starting with 'grackle-' | |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/grackle-') | |
steps: | |
- uses: actions/download-artifact@v5 | |
with: | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- name: Generate artifact attestations | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-path: "dist/*" | |
- name: Publish to pypi | |
uses: pypa/gh-action-pypi-publish@release/v1 |