File tree 1 file changed +20
-5
lines changed
1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change 18
18
details :
19
19
name : Extract Tag Details and Pre-checks
20
20
runs-on : ubuntu-latest
21
- environment : release-with-approval
22
21
permissions :
23
22
contents : read
24
23
outputs :
95
94
needs : [setup_and_build]
96
95
runs-on : ubuntu-latest
97
96
permissions :
98
- contents : read
99
- actions : write
100
97
id-token : write
101
98
steps :
102
99
- name : Download Artifacts
@@ -105,7 +102,25 @@ jobs:
105
102
name : dist
106
103
path : dist/
107
104
105
+ - name : Mint API Token
106
+ id : mint-token
107
+ run : |
108
+ # Retrieve the OIDC token
109
+ resp=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
110
+ "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=pypi")
111
+ oidc_token=$(jq -r '.value' <<< "${resp}")
112
+
113
+ # Exchange the OIDC token for a PyPI API token
114
+ resp=$(curl -X POST https://pypi.org/_/oidc/mint-token -d "{\"token\": \"${oidc_token}\"}")
115
+ api_token=$(jq -r '.token' <<< "${resp}")
116
+
117
+ # Mask the API token to prevent leaks
118
+ echo "::add-mask::${api_token}"
119
+
120
+ # Store API token as an output
121
+ echo "api-token=${api_token}" >> "${GITHUB_OUTPUT}"
122
+
108
123
- name : Publish Distribution
109
- uses : pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70
124
+ uses : pypa/gh-action-pypi-publish@release/v1
110
125
with :
111
- password : ${{ secrets.PYPI_TOKEN }}
126
+ password : ${{ steps.mint-token.outputs.api-token }}
You can’t perform that action at this time.
0 commit comments