Build, test and deploy to PyPI #16
Workflow file for this run
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, test and deploy to PyPI | |
on: | |
workflow_dispatch: | |
inputs: | |
upload_pypi: | |
description: 'Upload to PyPI?' | |
required: true | |
default: false | |
type: boolean | |
release: | |
types: | |
- published | |
jobs: | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
# macos-13 is an intel runner, macos-14 is apple silicon | |
os: [ubuntu-latest, windows-latest, macos-13, macos-14] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v2.21.1 | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./wheelhouse/*.whl | |
name: wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
build_sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build sdist | |
run: pipx run build --sdist | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.tar.gz | |
name: wheels-sdist | |
upload_pypi: | |
name: Upload to PyPI | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'release' || github.event.inputs.upload_pypi == 'true' }} | |
environment: | |
name: pypi | |
url: https://pypi.org/p/opticalmapping | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: wheels-* | |
path: dist | |
merge-multiple: true | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |