Skip to content

Commit fef0d83

Browse files
committed
Add trusted publishing
1 parent 231a977 commit fef0d83

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

.github/workflows/pypi.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ jobs:
2121
make_sdist:
2222
name: Make SDist
2323
runs-on: ubuntu-latest
24+
permissions:
25+
# write id-token and attestations are required to attest build provenance
26+
id-token: write
27+
attestations: write
2428
steps:
2529
- uses: actions/checkout@v4
2630
with:
@@ -30,6 +34,11 @@ jobs:
3034
- name: Build SDist
3135
run: pipx run build --sdist
3236

37+
- name: Attest GitHub build provenance
38+
uses: actions/attest-build-provenance@v1
39+
with:
40+
subject-path: dist/*.tar.gz
41+
3342
- uses: actions/upload-artifact@v4
3443
with:
3544
name: sdist
@@ -50,6 +59,10 @@ jobs:
5059
build_wheels:
5160
name: Build wheels for ${{ matrix.platform }}
5261
runs-on: ${{ matrix.platform }}
62+
permissions:
63+
# write id-token and attestations are required to attest build provenance
64+
id-token: write
65+
attestations: write
5366
strategy:
5467
matrix:
5568
platform:
@@ -64,6 +77,11 @@ jobs:
6477
- name: Build wheels
6578
uses: pypa/[email protected]
6679

80+
- name: Attest GitHub build provenance
81+
uses: actions/attest-build-provenance@v1
82+
with:
83+
subject-path: ./wheelhouse/*.whl
84+
6785
- uses: actions/upload-artifact@v4
6886
with:
6987
name: wheels-${{ matrix.platform }}
@@ -72,6 +90,10 @@ jobs:
7290
build_universal_wheel:
7391
name: Build universal wheel for Pyodide
7492
runs-on: ubuntu-latest
93+
permissions:
94+
# write id-token and attestations are required to attest build provenance
95+
id-token: write
96+
attestations: write
7597
steps:
7698
- uses: actions/checkout@v4
7799
with:
@@ -89,6 +111,11 @@ jobs:
89111
run: |
90112
PYODIDE=1 python setup.py bdist_wheel --universal
91113
114+
- name: Attest GitHub build provenance
115+
uses: actions/attest-build-provenance@v1
116+
with:
117+
subject-path: dist/*.whl
118+
92119
- uses: actions/upload-artifact@v4
93120
with:
94121
name: universal_wheel
@@ -125,6 +152,10 @@ jobs:
125152

126153
upload_pypi:
127154
name: Upload to PyPI on release
155+
environment: release
156+
permissions:
157+
# write id-token is required for upload attestation
158+
id-token: write
128159
needs: [check_dist]
129160
runs-on: ubuntu-latest
130161
if: github.event_name == 'release' && github.event.action == 'published'
@@ -146,6 +177,3 @@ jobs:
146177
path: dist
147178

148179
- uses: pypa/[email protected]
149-
with:
150-
user: __token__
151-
password: ${{ secrets.pypi_password }}

0 commit comments

Comments
 (0)