Skip to content
Latchkey

twine upload: Publish to PyPI Command Reference

Publish your built wheels and sdists to an index.

twine uploads distributions to PyPI (or a private index) over HTTPS. Run python -m build first, then "twine upload dist/*" to publish.

Common flags / usage

  • twine upload dist/* -- upload everything in dist/
  • -r, --repository NAME -- upload to a configured repository
  • --repository-url URL -- upload to an explicit index URL
  • --skip-existing -- do not fail if a version already exists
  • auth via TWINE_USERNAME=__token__ and TWINE_PASSWORD env vars

Example

shell
- run: python -m pip install twine
- env:
    TWINE_USERNAME: __token__
    TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
  run: |
    python -m twine check dist/*
    python -m twine upload --skip-existing dist/*

In CI

Authenticate with an API token: username __token__ and the token as the password, passed via env vars so the secret stays out of logs. Run twine check first to catch metadata errors before the upload.

Key takeaways

  • twine upload publishes dist/ artifacts to PyPI or a private index.
  • Authenticate with __token__ and an API token through env vars.
  • Run twine check before uploading to catch metadata problems.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →