File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ on :
2+ release :
3+ types :
4+ - published
5+
6+ name : release
7+
8+ jobs :
9+ pypi :
10+ name : upload release to PyPI
11+ runs-on : ubuntu-latest
12+ permissions :
13+ id-token : write
14+ steps :
15+ - uses : actions/checkout@v3
16+
17+ - uses : actions/setup-python@v4
18+ with :
19+ python-version : " 3.x"
20+
21+ - name : deps
22+ run : python -m pip install -U build
23+
24+ - name : build
25+ run : python -m build
26+
27+ - name : mint API token
28+ id : mint-token
29+ run : |
30+ # retrieve the ambient OIDC token
31+ resp=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
32+ "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=pypi")
33+ oidc_token=$(jq -r '.value' <<< "${resp}")
34+
35+ # exchange the OIDC token for an API token
36+ resp=$(curl -X POST https://pypi.org/_/oidc/mint-token -d "{\"token\": \"${oidc_token}\"}")
37+ api_token=$(jq -r '.token' <<< "${resp}")
38+
39+ # mask the newly minted API token, so that we don't accidentally leak it
40+ echo "::add-mask::${api_token}"
41+
42+ # see the next step in the workflow for an example of using this step output
43+ echo "api-token=${api_token}" >> "${GITHUB_OUTPUT}"
44+
45+ - name : publish
46+ # gh-action-pypi-publish uses TWINE_PASSWORD automatically
47+ uses : pypa/gh-action-pypi-publish@release/v1
48+ with :
49+ password : ${{ steps.mint-token.outputs.api-token }}
You can’t perform that action at this time.
0 commit comments