Build Wheels + PyPI deploy #76
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 + PyPI deploy | |
on: | |
workflow_dispatch: | |
inputs: | |
deploy_to_testpypi: | |
description: "Whether the build should be deployed to test.pypi.org" | |
required: true | |
default: "false" | |
deploy_to_pypi: | |
description: "Whether the build should be deployed to pypi.org" | |
required: true | |
default: "true" | |
jobs: | |
build-wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-24.04 | |
- os: windows-2022 | |
- os: macos-13 | |
target: "13.0" | |
- os: macos-14 | |
target: "14.0" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.target }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.os }} | |
path: ./wheelhouse/*.whl | |
build-sdist: | |
name: Build source distribution | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Build SDist | |
run: pipx run build --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: sdist | |
path: dist/*.tar.gz | |
test-sdist: | |
name: Test source distribution on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
needs: [build-sdist] | |
strategy: | |
matrix: | |
os: | |
- ubuntu-24.04 | |
- windows-2022 | |
- macos-14 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: '3.9' | |
- uses: actions/download-artifact@v4 | |
with: | |
name: sdist | |
path: dist | |
- name: Install OpenMP | |
if: runner.os == 'macOS' | |
run: brew install libomp | |
- name: Install from SDist | |
shell: bash | |
run: | |
python -m pip install dist/*.tar.gz | |
- name: Install test requirements | |
run: | |
python -m pip install -r requirements-dev.txt | |
- name: Run test suite | |
run: | |
python -m pytest | |
upload_testpypi: | |
needs: [build-sdist, test-sdist, build-wheels] | |
runs-on: ubuntu-24.04 | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: sdist | |
merge-multiple: true | |
path: dist | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: wheels-* | |
merge-multiple: true | |
path: dist | |
- uses: pypa/gh-action-pypi-publish@release/v1 | |
if: github.event.inputs.deploy_to_testpypi == 'true' | |
with: | |
repository_url: https://test.pypi.org/legacy/ | |
upload_pypi: | |
needs: [build-sdist, build-wheels, upload_testpypi] | |
runs-on: ubuntu-24.04 | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: sdist | |
merge-multiple: true | |
path: dist | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: wheels-* | |
merge-multiple: true | |
path: dist | |
- uses: pypa/gh-action-pypi-publish@release/v1 | |
if: github.event.inputs.deploy_to_pypi == 'true' |