-
Notifications
You must be signed in to change notification settings - Fork 1.1k
recommend TESTPYPI_ID_TOKEN for releasing to TestPyPi in docs #19565
Description
Describe the bug
Publishing to TestPyPi with a trusted publisher (GitLab) does not work when following the documentation in
https://docs.pypi.org/trusted-publishers/using-a-publisher/#gitlab-cicd
The problem appears to be that you need to rename PYPI_ID_TOKEN to TESTPYPI_ID_TOKEN in .gitlab-ci.yml
I will make a PR with an update of the documentation shortly after this.
Expected behavior
A release to TestPyPi.
To Reproduce
shortened .gitlab-ci.yml
release-test-pypi:
[...]
id_tokens:
PYPI_ID_TOKEN:
aud: testpypi
script:
- pip install -U twine
- twine upload -r testpypi dist/* --verbose
I get the following output (shortened)
$ twine upload -r testpypi dist/* --verbose
Uploading distributions to https://test.pypi.org/legacy/
INFO dist/your_python_package_1234-1.0.0-py3-none-any.whl (12.4 KB)
INFO dist/your_python_package_1234-1.0.0.tar.gz (10.0 KB)
INFO username set by command options
INFO Querying keyring for password
INFO No keyring backend found
INFO Trying to use trusted publishing (no token was explicitly provided)
ERROR TrustedPublishingFailure: Unable to retrieve an OIDC token from the CI
platform for trusted publishing GitLab: Environment variable
TESTPYPI_ID_TOKEN not found
After changing the YAML to
release-test-pypi:
[...]
id_tokens:
TESTPYPI_ID_TOKEN:
aud: testpypi
script:
- pip install -U twine
- twine upload -r testpypi dist/* --verbose
the release to TestPyPi is successful.
My Platform
I ran the test release in a GitLab protected environment using python:3.13-slim as an image. The build was done with Hatch.
Additional context
TLDR: use TESTPYPI_ID_TOKEN instead of PYPI_ID_TOKEN for trusted publishing with GitLab.
I have added a small comment to the docs and will create a PR now.