Ci #61
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: Wheels | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- main | |
tag: | |
- '*' | |
release: | |
types: | |
- published | |
env: | |
# Python 3.12+ is handled using the stable ABI, no need to build later versions | |
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8, <=3.12" | |
# Only build for PyPy 3.9 | |
# CIBW_SKIP: "pp37* pp38*" | |
CIBW_BUILD: "cp310-manylinux_x86_64" # for testing, build single wheel. | |
# Target 64 bit architectures (x86_64, and arm64 on macOS) | |
CIBW_ARCHS_WINDOWS: auto64 | |
CIBW_ARCHS_LINUX: auto64 | |
CIBW_ARCHS_MACOS: x86_64 arm64 | |
# Target older versions of macOS and Linux for good compatibility | |
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=10.14 | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 | |
# Necessary to see build output from the actual compilation | |
CIBW_BUILD_VERBOSITY: 1 | |
# Temporary: use pre-release Python 3.12 for stable API builds | |
CIBW_PRERELEASE_PYTHONS: True | |
# GitHub Actions doesn't have macOS/arm64 runners, skip test on this platform | |
CIBW_TEST_SKIP: "*-macosx_arm64" | |
# Run pytest to ensure that the package was correctly built | |
CIBW_TEST_COMMAND: pytest {project}/tests | |
CIBW_TEST_REQUIRES: pytest | |
jobs: | |
build_sdist: | |
name: Build SDist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Build SDist | |
run: pipx run build --sdist | |
- name: Check metadata | |
run: pipx run twine check dist/* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-sdist | |
path: dist/*.tar.gz | |
build_wheels: | |
name: Wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' || github.event_name == 'release' | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: build wheels | |
uses: pypa/[email protected] | |
- name: Verify clean directory | |
run: git diff --exit-code | |
shell: bash | |
- name: upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} # unique name for the artifact | |
path: wheelhouse/*.whl # location of the wheels | |
upload_to_pypi: | |
name: Upload if release | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
# run on published release or manual trigger | |
if: github.event_name == 'release' && github.event.action == 'published' || github.event_name == 'workflow_dispatch' | |
permissions: # Added OIDC permissions | |
contents: read | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
steps: | |
- uses: actions/setup-python@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: cibw-* # download all artifacts | |
path: dist | |
merge-multiple: true | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
upload_to_test_pypi: | |
# runs for distributions or tags | |
name: Upload to Test PyPI | |
needs: [build_wheels, build_sdist] | |
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
permissions: # Added OIDC permissions | |
contents: read | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
steps: | |
- uses: actions/setup-python@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: cibw-* # download all artifacts | |
path: dist | |
merge-multiple: true | |
- name: Publish package distributions to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
skip-existing: false |