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 :
3135 - name : Build SDist
3236 run : pipx run build --sdist
3337
38+ - name : Attest GitHub build provenance
39+ uses : actions/attest-build-provenance@v1
40+ with :
41+ subject-path : dist/*.tar.gz
42+
3443 - uses : actions/upload-artifact@v4
3544 with :
3645 name : sdist
5261 build_wheels :
5362 name : Build wheels for ${{ matrix.platform }}
5463 runs-on : ${{ matrix.platform }}
64+ permissions :
65+ # write id-token and attestations are required to attest build provenance
66+ id-token : write
67+ attestations : write
5568 strategy :
5669 matrix :
5770 platform :
6780 - name : Build wheels
68816982
83+ - name : Attest GitHub build provenance
84+ uses : actions/attest-build-provenance@v1
85+ with :
86+ subject-path : ./wheelhouse/*.whl
87+
7088 - uses : actions/upload-artifact@v4
7189 with :
7290 name : wheels-${{ matrix.platform }}
7593 build_universal_wheel :
7694 name : Build universal wheel for Pyodide
7795 runs-on : ubuntu-latest
96+ permissions :
97+ # write id-token and attestations are required to attest build provenance
98+ id-token : write
99+ attestations : write
78100 steps :
79101 - uses : actions/checkout@v4
80102 with :
@@ -93,6 +115,11 @@ jobs:
93115 run : |
94116 PYODIDE=1 python setup.py bdist_wheel --universal
95117
118+ - name : Attest GitHub build provenance
119+ uses : actions/attest-build-provenance@v1
120+ with :
121+ subject-path : dist/*.whl
122+
96123 - uses : actions/upload-artifact@v4
97124 with :
98125 name : universal_wheel
@@ -129,9 +156,16 @@ jobs:
129156
130157 upload_pypi :
131158 name : Upload to PyPI on release
159+ # Use the `release` GitHub environment to protect the Trusted Publishing (OIDC)
160+ # workflow by requiring signoff from a maintainer.
161+ environment : release
162+ permissions :
163+ # write id-token is required for trusted publishing (OIDC)
164+ id-token : write
132165 needs : [check_dist]
133166 runs-on : ubuntu-latest
134- if : github.event_name == 'release' && github.event.action == 'published'
167+ # Don't publish from forks
168+ if : github.repository_owner == 'pymc-devs' && github.event_name == 'release' && github.event.action == 'published'
135169 steps :
136170 - uses : actions/download-artifact@v4
137171 with :
@@ -150,6 +184,4 @@ jobs:
150184 path : dist
151185
152186153- with :
154- user : __token__
155- password : ${{ secrets.pypi_password }}
187+ # Implicitly attests that the packages were uploaded in the context of this workflow.
0 commit comments