I’m having trouble getting authentication to PyPI working when uploading. TWINE_USERNAME and TWINE_PASSWORD are defined in the GitLab CI/CD variable settings. I can get this to work using the same commands locally but when using them in the pipeline it returns a 403 Forbidden error. I am using token authentication and setting the username as __token__ as described in the documentation. I know the credentials are good because when I try to use them locally the package uploads fine. Just not sure what else to try. Any help or ideas would be much appreciated.
Relevant gitlab-ci.yml portion:
deploy:
image: python:3.10
stage: deploy
only:
- tags
variables:
TWINE_USERNAME: $TWINE_USERNAME
TWINE_PASSWORD: $TWINE_PASSWORD
script:
- pip install twine build
- python -m build
- python -m twine upload dist/*
Error message:
HTTPError: 403 Forbidden from upload.pypi.org · PyPI
Invalid or non-existent authentication information. See
Help · PyPI for more information.