Merge pull request #239 from jakevdp:py313-ci #318
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-14, windows-2019] | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
submodules: true | |
# Used to host cibuildwheel | |
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 | |
with: | |
python-version: "3.9" | |
- name: Set up QEMU | |
if: runner.os == 'Linux' | |
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 | |
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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
submodules: true | |
- name: Build sdist | |
run: pipx run build --sdist | |
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
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 # v4.1.8 | |
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 # v4.1.8 | |
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@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2 |