Skip to content

Commit 0472720

Browse files
Marcus G K WilliamsMarcus G K Williams
authored andcommitted
Update release job, pypi auth
Signed-off-by: Marcus G K Williams <Marcus G K Williams 168222+mgkwill@users.noreply.github.com>
1 parent 291fb3f commit 0472720

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

.github/workflows/cd.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,29 @@ jobs:
181181
generateReleaseNotes: true
182182
makeLatest: true
183183

184+
- name: Mint Github API token
185+
id: mint-token
186+
run: |
187+
# retrieve the ambient OIDC token
188+
resp=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
189+
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=pypi")
190+
oidc_token=$(jq '.value' <<< "${resp}")
191+
192+
# exchange the OIDC token for an API token
193+
resp=$(curl -X POST https://pypi.org/_/oidc/github/mint-token -d "{\"token\": \"${oidc_token}\"}")
194+
api_token=$(jq '.token' <<< "${resp}")
195+
196+
# mask the newly minted API token, so that we don't accidentally leak it
197+
echo "::add-mask::${api_token}"
198+
199+
# see the next step in the workflow for an example of using this step output
200+
echo "api-token=${api_token}" >> "${GITHUB_OUTPUT}"
201+
184202
- name: Publish to PyPI
185203
if: steps.check-version.outputs.prerelease != 'true'
186204
env:
187-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
205+
POETRY_PYPI_TOKEN_PYPI: ${{ steps.mint-token.outputs.api-token }}
188206
run: |
189207
mkdir dist
190208
cp lava* dist/.
191-
# poetry config repositories.testpypi https://test.pypi.org/legacy/
192209
poetry publish --dry-run

0 commit comments

Comments
 (0)