Skip to content

Publishing

Publishing #6

Workflow file for this run

name: Publishing
on:
workflow_dispatch:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flit
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
- name: create API token
id: 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: Build and publish
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ steps.token.outputs.api-token }}
run: |
flit publish