Skip to content

Commit 0d4b0a8

Browse files
ci: Use PyPI Trusted Publisher for publishing package (#294)
* Use the OpenID Connect (OIDC) standard to publish to PyPI and TestPyPI using PyPI's "Trusted Publisher" implementation to publish without using API tokens stored as GitHub Actions secrets. Use an optional GitHub Actions environment to further restrict publishing to selected branches for additional security. - c.f. https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/ - c.f. https://docs.pypi.org/trusted-publishers/
1 parent 02663e3 commit 0d4b0a8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

.github/workflows/wheels.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ jobs:
9797
upload_all:
9898
needs: [build_wheels, make_sdist]
9999
runs-on: ubuntu-latest
100+
# Restrict to the environment set for the trusted publisher
101+
environment:
102+
name: publish
103+
# Mandatory for publishing with a trusted publisher
104+
# c.f. https://docs.pypi.org/trusted-publishers/using-a-publisher/
105+
permissions:
106+
id-token: write
100107
if: github.event_name == 'release' && github.event.action == 'published'
101108

102109
steps:
@@ -108,6 +115,4 @@ jobs:
108115

109116
- uses: pypa/gh-action-pypi-publish@release/v1
110117
with:
111-
user: __token__
112-
# Remember to generate this and set it in "GitHub Secrets"
113-
password: ${{ secrets.pypi_password }}
118+
print-hash: true

0 commit comments

Comments
 (0)