poetry publish: Publish to PyPI
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 one step.
What it does
Uploads dist/ artifacts to a package index. --build builds first; --repository selects a non-default repository configured via poetry config.
Common usage
Terminal
poetry publish --build
poetry publish -r my-private-repo
poetry publish --dry-runCommon CI auth: PyPI token via env
Authenticate non-interactively by exporting a PyPI API token. Poetry reads POETRY_PYPI_TOKEN_PYPI for the default PyPI repository.
Terminal
export POETRY_PYPI_TOKEN_PYPI="${PYPI_API_TOKEN}"
poetry publish --build --no-interaction