Skip to content
Latchkey

poetry publish: Publish to PyPI Command Reference

Push your built package to an index from CI.

poetry publish uploads the artifacts in dist/ to PyPI or a configured repository. Pair it with --build to build and publish in a single step.

Common flags / usage

  • poetry publish -- upload existing dist/ artifacts
  • --build -- build first, then publish
  • -r, --repository NAME -- target a non-default repository
  • --dry-run -- show what would be uploaded
  • auth via POETRY_PYPI_TOKEN_PYPI env var

Example

shell
- env:
    POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
  run: poetry publish --build --no-interaction

In CI

Authenticate non-interactively by exporting a PyPI API token; Poetry reads POETRY_PYPI_TOKEN_PYPI for the default PyPI repository. Use --dry-run in a pre-release check to confirm the artifacts without shipping.

Key takeaways

  • poetry publish uploads dist/ artifacts to an index.
  • --build builds and publishes in one command.
  • Authenticate via the POETRY_PYPI_TOKEN_PYPI environment variable.

Related guides

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