Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 54 additions & 7 deletions .github/workflows/python-wheel-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,35 @@ jobs:
run: |
mkdir -p python/dist
find dist -name "*" -type f -exec mv {} python/dist/ \;
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Set up Python
uses: actions/setup-python@v5
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: python/dist/
python-version: "3.x"

- name: Publish to Test PyPI
run: |
set -euo pipefail
pip install twine

# Mint a short-lived API token via PyPI Trusted Publisher (OIDC)
OIDC_TOKEN=$(curl -sS \
-H "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=testpypi" \
| python3 -c "import sys, json; print(json.load(sys.stdin)['value'])")

PYPI_TOKEN=$(curl -sS -X POST \
https://test.pypi.org/_/oidc/mint-token \
-H "Content-Type: application/json" \
-d "{\"token\": \"${OIDC_TOKEN}\"}" \
| python3 -c "import sys, json; print(json.load(sys.stdin)['token'])")
echo "::add-mask::${PYPI_TOKEN}"

twine upload \
--repository-url https://test.pypi.org/legacy/ \
--username __token__ \
--password "${PYPI_TOKEN}" \
--skip-existing \
python/dist/*

upload_pypi:
name: Publish (manual)
Expand All @@ -297,7 +321,30 @@ jobs:
run: |
mkdir -p python/dist
find dist -name "*" -type f -exec mv {} python/dist/ \;
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/2473ec6c6aa87f38946284d51289219fd0b87264
- name: Set up Python
uses: actions/setup-python@v5
with:
packages-dir: python/dist/
python-version: "3.x"

- name: Publish to PyPI
run: |
set -euo pipefail
pip install twine

# Mint a short-lived API token via PyPI Trusted Publisher (OIDC)
OIDC_TOKEN=$(curl -sS \
-H "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=pypi" \
| python3 -c "import sys, json; print(json.load(sys.stdin)['value'])")

PYPI_TOKEN=$(curl -sS -X POST \
https://pypi.org/_/oidc/mint-token \
-H "Content-Type: application/json" \
-d "{\"token\": \"${OIDC_TOKEN}\"}" \
| python3 -c "import sys, json; print(json.load(sys.stdin)['token'])")
echo "::add-mask::${PYPI_TOKEN}"

twine upload \
--username __token__ \
--password "${PYPI_TOKEN}" \
python/dist/*
Loading