Skip to content

Commit

Permalink
Use Trusted Publisher to deploy to PyPI (#160)
Browse files Browse the repository at this point in the history
Replaces the API tokens. This is the way PyPI recommends deploying.
  • Loading branch information
leouieda authored Mar 13, 2024
1 parent a11f32b commit 1cd26b0
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 @@ -84,6 +84,10 @@ jobs:
needs: build
# Only publish from the origin repository, not forks
if: github.repository_owner == 'fatiando' && 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 @@ -103,10 +107,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 @@ -115,7 +117,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 1cd26b0

Please sign in to comment.