Skip to content

Commit

Permalink
Use PyPI Trusted Publishers instead of API tokens (#67)
Browse files Browse the repository at this point in the history
The new setting allows us to configure Actions as a trusted publisher on
PyPI so we don't need to store long-lived API tokens for deployment.
  • Loading branch information
leouieda authored Apr 9, 2024
1 parent 7a78128 commit bcfcf80
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ jobs:
needs: build
# Only publish from the origin repository, not forks
if: github.repository_owner == 'compgeolab' && github.event_name != 'pull_request'
environment: pypi
permissions:
# This permission allows trusted publishing to PyPI (without an API token)
id-token: write

steps:
- name: Checkout
Expand All @@ -110,10 +114,8 @@ jobs:
- name: Publish to Test PyPI
# Only publish to TestPyPI when a PR is merged (pushed to main)
if: success() && github.event_name == 'push'
uses: pypa/gh-action-pypi-publish@bce3b74dbf8cc32833ffba9d15f83425c1a736e0
uses: pypa/gh-action-pypi-publish@v1.8.12
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
# Allow existing releases on test PyPI without errors.
# NOT TO BE USED in PyPI!
Expand All @@ -122,7 +124,4 @@ jobs:
- name: Publish to PyPI
# Only publish to PyPI when a release triggers the build
if: success() && github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@bce3b74dbf8cc32833ffba9d15f83425c1a736e0
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
uses: pypa/[email protected]

0 comments on commit bcfcf80

Please sign in to comment.