cookie
cookie copied to clipboard
feat: Use Trusted Publishers with GitLab CI/CD
- PyPI Trusted Publisher support now includes GitLab CI/CD, so use generated OIDC tokens to publish to TestPyPI or PyPI as needed in GitLab pipelines.
- c.f. https://blog.pypi.org/posts/2024-04-17-expanding-trusted-publisher-support/
Since twine 6.1.0, uploading with Trusted Publishing on GitLab CI/CD is automatically detected, and doesn't need any of the manual steps that were needed before (other than adding the id_tokens section). For example:
publish-job:
stage: deploy
image: python:3-bookworm
id_tokens:
PYPI_ID_TOKEN:
aud: pypi
script:
- python -m pip install -U twine
- twine upload python_pkg/dist/*
See the updated docs here: https://docs.pypi.org/trusted-publishers/using-a-publisher/#gitlab-cicd