Publish to PyPI #63
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
# This is based on pyca/cryptography but we use cibuildwheel | |
# https://github.com/pyca/cryptography/blob/50ae9623df9181e5d08bbca0791ae69af4d3d446/.github/workflows/pypi-publish.yml | |
name: Publish to PyPI | |
on: | |
workflow_dispatch: | |
inputs: | |
run_id: | |
description: The run of wheel-builder to use for finding artifacts. | |
required: true | |
environment: | |
description: Which PyPI environment to upload to | |
required: true | |
type: choice | |
options: [testpypi, pypi] | |
workflow_run: | |
workflows: ["Wheel Builder"] | |
types: [completed] | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
# We're not actually verifying that the triggering push event was for a | |
# tag, because github doesn't expose enough information to do so. | |
# wheel-builder.yml currently only has push events for tags. | |
if: github.event_name == 'workflow_dispatch' || (github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success') | |
environment: publish | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifacts | |
uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d # v3.0.0 | |
with: | |
path: artifacts/ | |
run_id: ${{ github.event.inputs.run_id || github.event.workflow_run.id }} | |
- name: Move artifacts to dist/ | |
run: | | |
ls -lR artifacts/ | |
mkdir dist | |
mv artifacts/sdist/*.tar.gz dist/ | |
mv artifacts/wheels-*/*.whl dist/ | |
- name: Publish to pypi.org | |
uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf # v1.8.11 | |
if: github.event_name == 'workflow_run' || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'pypi') | |
with: | |
packages-dir: dist/ | |
- name: Publish to test.pypi.org | |
uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf # v1.8.11 | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'testpypi' | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
packages-dir: dist/ |