Skip to content

Commit 8880cb6

Browse files
authored
Merge pull request #173 from CliMT/develop
Updating twine upload
2 parents 54d0342 + 2477975 commit 8880cb6

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

.github/workflows/release_climt.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,28 @@ jobs:
5656
- name: Install twine
5757
run: python -m pip install twine
5858

59-
- name: upload wheels
60-
env:
61-
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
62-
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
63-
run: twine upload wheelhouse/* --verbose
59+
- name: mint API token
60+
id: mint-token
61+
run: |
62+
# retrieve the ambient OIDC token
63+
resp=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
64+
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=pypi")
65+
oidc_token=$(jq -r '.value' <<< "${resp}")
66+
67+
# exchange the OIDC token for an API token
68+
resp=$(curl -X POST https://pypi.org/_/oidc/mint-token -d "{\"token\": \"${oidc_token}\"}")
69+
api_token=$(jq -r '.token' <<< "${resp}")
70+
71+
# mask the newly minted API token, so that we don't accidentally leak it
72+
echo "::add-mask::${api_token}"
73+
74+
# see the next step in the workflow for an example of using this step output
75+
echo "api-token=${api_token}" >> "${GITHUB_OUTPUT}"
76+
77+
TWINE_USERNAME=__token__ TWINE_PASSWORD=${api_token} twine upload wheelhouse/* --verbose
78+
79+
# - name: upload wheels
80+
# env:
81+
# TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
82+
# TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
83+
# run: twine upload wheelhouse/* --verbose

0 commit comments

Comments
 (0)