Publish to PyPI #40
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@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.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@b7f401de30cb6434a1e19f805ff006643653240e # v1.8.10 | |
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@b7f401de30cb6434a1e19f805ff006643653240e # v1.8.10 | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'testpypi' | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
packages-dir: dist/ |