Skip to content

Commit

Permalink
Add PyPI trusted publishing for Test PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
alugowski committed Oct 16, 2023
1 parent 83a67e9 commit b834ce2
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ name: wheels

on:
workflow_dispatch:
inputs:
# Manual dispatch allows optional upload of wheels to PyPI
upload_dest:
type: choice
description: Upload wheels to
options:
- No Upload
- PyPI
- Test PyPI
release:
types:
- published
Expand All @@ -10,6 +19,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
# For PyPI Trusted Publisher
id-token: write

jobs:
publish_PyPI:
name: Publish to PyPI
Expand All @@ -29,13 +42,16 @@ jobs:
- name: Check
run: pipx run twine check dist/*

# Upload to PyPI
- uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest == 'PyPI')
with:
# PyPI does not allow replacing a file. Without this flag the entire action fails if even a single duplicate exists.
skip-existing: true
verbose: true
# Real PyPI:
password: ${{ secrets.PYPI_API_TOKEN }}
# Test PyPI:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository-url: https://test.pypi.org/legacy/

# Upload to Test PyPI
- uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest == 'Test PyPI'
with:
verbose: true
repository-url: https://test.pypi.org/legacy/

0 comments on commit b834ce2

Please sign in to comment.