39
39
ssh_private_signing_key : ${{ secrets.SEMANTIC_RELEASE_PRIVATE_KEY }}
40
40
ssh_public_signing_key : ${{ secrets.SEMANTIC_RELEASE_PUBLIC_KEY }}
41
41
42
+ - name : Hash Build Artifacts
43
+ if : steps.release.outputs.released == 'true'
44
+ id : hash
45
+ run : |
46
+ cd dist
47
+ echo "hashes=$(find . -type f -exec sha256sum {} + | sort | base64 | tr -d '\n')" >> "$GITHUB_OUTPUT"
48
+
42
49
- name : Upload Build Artifacts
43
50
if : steps.release.outputs.released == 'true'
44
51
uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
@@ -47,13 +54,28 @@ jobs:
47
54
path : dist/
48
55
49
56
outputs :
57
+ hashes : ${{ steps.hash.outputs.hashes }}
50
58
released : ${{ steps.release.outputs.released }}
51
59
52
- publish :
53
- runs-on : ubuntu-latest
60
+ provenance :
54
61
needs : release
55
62
if : ${{ needs.release.outputs.released == 'true' }}
63
+ permissions :
64
+ actions : read
65
+ id-token : write
66
+ contents : write
67
+ uses :
slsa-framework/slsa-github-generator/.github/workflows/[email protected]
68
+ with :
69
+ base64-subjects : " ${{ needs.release.outputs.hashes }}"
70
+
71
+ publish :
72
+ runs-on : ubuntu-latest
73
+ needs : [release, provenance]
74
+ if : ${{ needs.release.outputs.released == 'true' && needs.provenance.outputs.outcome == 'success' }}
56
75
environment : release
76
+ permissions :
77
+ id-token : write
78
+
57
79
steps :
58
80
- name : Harden Runner
59
81
uses : step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
@@ -65,16 +87,25 @@ jobs:
65
87
fetch-depth : 0
66
88
token : ${{ secrets.GH_TOKEN }}
67
89
68
- - name : Download Artifacts
90
+ - name : Download Build Artifacts
69
91
uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
70
92
with :
71
93
name : dist
72
94
path : dist
73
95
74
- - name : Publish to PyPI
75
- uses : pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1
96
+ - name : Download Provenance
97
+ uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
98
+ with :
99
+ name : ${{ needs.provenance.outputs.provenance-name }}
100
+ path : dist
76
101
77
102
- name : Publish to GitHub Releases
78
103
uses : python-semantic-release/publish-action@b717f67f7e7e9f709357bce5a542846503ce46ec # v10.2.0
79
104
with :
80
105
github_token : ${{ secrets.GH_TOKEN }}
106
+
107
+ - name : Remove Provenance for PyPI Upload
108
+ run : rm -f dist/${{ needs.provenance.outputs.provenance-name }}
109
+
110
+ - name : Publish to PyPI
111
+ uses : pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1
0 commit comments