Skip to content

Commit

Permalink
Update the workflow configs to use OIDC token
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed May 4, 2023
1 parent e7b230a commit 23360b4
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ jobs:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
environment: deploy-to-pypi
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Checkout sources
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
Expand All @@ -122,12 +125,23 @@ jobs:
cache-dependency-path: |
requirements/build.txt
- name: Install dependencies
env:
REQUIREMENTS_FILE: build
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U pip setuptools
pip install -U -r requirements/build.txt
- name: Build and publish
- name: Build sdist and wheel
run: |
python -m build -s -w
twine upload dist/*
- name: Mint API token
id: mint-token
run: |
resp=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=pypi")
oidc_token=$(jq '.value' <<< "${resp}")
resp=$(curl -X POST https://pypi.org/_/oidc/github/mint-token -d "{\"token\": \"${oidc_token}\"}")
api_token=$(jq '.token' <<< "${resp}")
echo "::add-mask::${api_token}"
echo "api-token=${api_token}" >> "${GITHUB_OUTPUT}"
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ steps.mint-token.outputs.api-token }}

0 comments on commit 23360b4

Please sign in to comment.