Skip to content

Commit ab14f96

Browse files
authored
ci: publish to PyPI with Trusted Publishing to get provenance (#691)
PyPI only stores PEP 740 attestations, and shows provenance, when the upload uses Trusted Publishing. Drop the PYPI_API_TOKEN password and run the job in a pypi environment that the trusted publisher names. Co-authored-by: Xianpeng Shen <[email protected]>
1 parent 17f4e06 commit ab14f96

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ jobs:
1313
permissions:
1414
id-token: write
1515
attestations: write
16+
# Must match the environment set in the PyPI trusted publisher.
17+
environment:
18+
name: pypi
19+
url: https://pypi.org/p/commit-check
1620
runs-on: ubuntu-24.04
1721
steps:
1822
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -33,7 +37,7 @@ jobs:
3337
# Build wheel. --no-deps is load-bearing: without it pip also writes
3438
# every dependency's wheel into dist/, and the publish step uploads
3539
# the whole directory (it has no file-selection input), so PyPI is
36-
# asked to accept someone else's package under our scoped token.
40+
# asked to accept someone else's package under our project.
3741
python -m pip wheel --no-deps -w dist .
3842
# Check distribution
3943
twine check dist/commit_check*
@@ -51,8 +55,8 @@ jobs:
5155
password: ${{ secrets.TEST_PYPI_TOKEN }}
5256
continue-on-error: true
5357

58+
# Trusted Publishing (OIDC, no token): PyPI then stores the PEP 740
59+
# attestations this action makes and shows provenance on the release.
5460
- name: Publish package to PyPI
5561
if: github.event_name != 'workflow_dispatch' && github.repository == 'commit-check/commit-check'
5662
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
57-
with:
58-
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)