Skip to content

Commit 39245ca

Browse files
committed
Fix instructions for GitLab CI with Trusted Publishing
1 parent 2da3278 commit 39245ca

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/user/trusted-publishers/using-a-publisher.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ below describe the setup process for each supported trusted publisher.
292292
stage: build
293293
image: python:3-bookworm
294294
script:
295-
- python -m pip install -U twine build
295+
- python -m pip install -U build
296296
- cd python_pkg && python -m build
297297
artifacts:
298298
paths:
@@ -305,6 +305,7 @@ below describe the setup process for each supported trusted publisher.
305305
- build-job
306306
id_tokens:
307307
PYPI_ID_TOKEN:
308+
# Use "testpypi" if uploading to TestPyPI
308309
aud: pypi
309310
script:
310311
# Install dependencies
@@ -313,9 +314,11 @@ below describe the setup process for each supported trusted publisher.
313314

314315
# Retrieve the OIDC token from GitLab CI/CD, and exchange it for a PyPI API token
315316
- oidc_token=$(python -m id PYPI)
317+
# Replace "https://pypi.org/*" with "https://test.pypi.org/*" if uploading to TestPyPI
316318
- resp=$(curl -X POST https://pypi.org/_/oidc/mint-token -d "{\"token\":\"${oidc_token}\"}")
317-
- api_token=$(jq '.token' <<< "${resp}")
319+
- api_token=$(jq --raw-output '.token' <<< "${resp}")
318320

319321
# Upload to PyPI authenticating via the newly-minted token
322+
# Add "--repository testpypi" if uploading to TestPyPI
320323
- twine upload -u __token__ -p "${api_token}" python_pkg/dist/*
321324
```

0 commit comments

Comments
 (0)