Merge pull request #201 from jakevdp:actions-concurrency #263
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 | |
on: | |
workflow_dispatch: {} # allows triggering this workflow manually | |
push: | |
branches: # trigger on commits to main branch | |
- main | |
pull_request: # trigger on pull requests affecting relevant files | |
branches: | |
- main | |
paths: | |
- '**workflows/wheels.yml' | |
- 'pyproject.toml' | |
release: # trigger on published release | |
types: | |
- published | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, macos-12, windows-2019] | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # ratchet:actions/checkout@v4 | |
with: | |
submodules: true | |
# Used to host cibuildwheel | |
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # ratchet:actions/setup-python@v5 | |
with: | |
python-version: "3.9" | |
- name: Set up QEMU | |
if: runner.os == 'Linux' | |
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # ratchet: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Install cibuildwheel | |
run: python -m pip install cibuildwheel==2.20.0 | |
- name: Build wheels | |
run: python -m cibuildwheel --output-dir wheelhouse | |
env: | |
# TODO(jakevdp): re-add 313t & free-threading support | |
CIBW_ARCHS_LINUX: auto aarch64 | |
CIBW_ARCHS_MACOS: universal2 | |
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-* # cp313t-* | |
# CIBW_FREE_THREADED_SUPPORT: True | |
CIBW_PRERELEASE_PYTHONS: True | |
CIBW_SKIP: "*musllinux* *i686* *win32* *t-win*" | |
CIBW_TEST_REQUIRES: absl-py pytest pytest-xdist | |
CIBW_TEST_COMMAND: pytest -n auto {project} | |
CIBW_BUILD_VERBOSITY: 1 | |
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # ratchet: 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: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # ratchet:actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Build sdist | |
run: pipx run build --sdist | |
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # ratchet: actions/upload-artifact@v4 | |
with: | |
name: cibw-sdist | |
path: dist/*.tar.gz | |
download_and_list_artifacts: | |
# Helps debug issues like https://github.com/jax-ml/ml_dtypes/issues/196 | |
name: Download and list artifacts | |
needs: [build_sdist, build_wheels] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # ratchet:actions/download-artifact@v4 | |
with: | |
# unpacks all CIBW artifacts into dist/ | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- name: List files | |
run: ls -l dist/ | |
upload_pypi: | |
name: Release & Upload to PyPI | |
needs: [build_sdist, build_wheels] | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
id-token: write | |
# Only publish release to PyPI when a github release is created. | |
if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # ratchet:actions/download-artifact@v4 | |
with: | |
# unpacks all CIBW artifacts into dist/ | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- name: List files | |
run: ls -l dist/ | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # ratchet:pypa/gh-action-pypi-publish@v1.9 |