File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,9 +12,34 @@ permissions:
1212 - RELEASES.md
1313 - ' */RELEASES.md'
1414jobs :
15+ mint-token :
16+ runs-on : ubuntu-latest
17+ permissions :
18+ contents : write
19+ id-token : write
20+ outputs :
21+ api-token : ${{ steps.mint-token.outputs.api-token }}
22+ steps :
23+ - name : Mint API token
24+ run : |
25+ # retrieve the ambient OIDC token
26+ resp=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
27+ "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=pypi")
28+ oidc_token=$(jq -r '.value' <<< "${resp}")
29+
30+ # exchange the OIDC token for an API token
31+ resp=$(curl -X POST https://pypi.org/_/oidc/mint-token -d "{\"token\": \"${oidc_token}\"}")
32+ api_token=$(jq -r '.token' <<< "${resp}")
33+
34+ # mask the newly minted API token, so that we don't accidentally leak it
35+ echo "::add-mask::${api_token}"
36+
37+ # see the next step in the workflow for an example of using this step output
38+ echo "api-token=${api_token}" >> "${GITHUB_OUTPUT}"
1539 publish :
40+ needs : mint-token
1641 uses : speakeasy-api/sdk-generation-action/.github/workflows/sdk-publish.yaml@v15
1742 secrets :
1843 github_access_token : ${{ secrets.GITHUB_TOKEN }}
19- pypi_token : ${{ secrets.PYPI_TOKEN }}
44+ pypi_token : ${{ needs.mint-token.outputs.api-token }}
2045 speakeasy_api_key : ${{ secrets.SPEAKEASY_API_KEY }}
You can’t perform that action at this time.
0 commit comments