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-interactionIn 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
poetry build: Build Artifacts Command ReferenceReference for poetry build in CI: producing a wheel and sdist into dist/ from pyproject.toml, the --format fl…
twine upload: Publish to PyPI Command ReferenceReference for twine upload in CI: publishing built distributions to PyPI or a private index, token authentica…
poetry install: Install from Lock Command ReferenceReference for poetry install in CI: installing from poetry.lock, the --no-root, --only, and --no-interaction…