- Create the initial project on PyPI manually via twine
- Create an API token for PyPI with it's scope limited to the project
- Add the API token to the GitLab project under CI/CD - Variables:
TWINE_USERNAME
=__token__
TWINE_PASSWORD
= The API Token. Starts withpypi-
- Set the variables as "Masked" to prevent them from showing up in log files
- Add a deploy section to your
.gitlab.ci.yaml
- To execute add a new tag to your commit
deploy-pypi:
stage: deploy
image: python:3.7-buster
before_script:
- pip install twine
script:
- python setup.py sdist
- twine upload dist/*
only:
- tags