-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use PyPI Trusted Publishers instead of API tokens (#67)
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
Showing
1 changed file
with
6 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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! | ||
|
@@ -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] |