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 and upload to PyPI | |
on: | |
# Allow manual triggering of the workflow, but note that the upload | |
# to PyPI step will not run manual trigger. | |
workflow_dispatch: | |
# Run workflow on pullrequests, but note that the upload to PyPI step | |
# will not run on pull requests. | |
pull_request: | |
# Run workflow on push to main branch, but note that the upload to | |
# PyPI step will not run on pushes. We could change that if we wanted | |
# to have it publish on tags -- see the upload_pypi job below. | |
push: | |
branches: | |
- main | |
# Run workflow on GitHub release done through the UI -- this is the only | |
# time the upload to PyPI step will run. | |
release: | |
types: | |
- published | |
jobs: | |
build_wheel_sdist: | |
name: Build wheel and sdist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build wheel and sdist | |
run: pipx run build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheel-sdist | |
path: dist/* | |
upload_pypi: | |
needs: [build_wheel_sdist] | |
runs-on: ubuntu-latest | |
environment: publish | |
permissions: | |
id-token: write | |
if: github.event_name == 'release' && github.event.action == 'published' | |
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) | |
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
# unpacks all CIBW artifacts into dist/ | |
pattern: wheel-sdist | |
path: dist | |
merge-multiple: true | |
- uses: pypa/gh-action-pypi-publish@release/v1 |