Example configuration for a Python package published to PyPI.
- Copy the
.github/folder to your repository - Add required secrets:
PYPI_TOKEN- PyPI API token (or use trusted publishing)
- Create PR labels in your repo
This example uses:
- uv for building and publishing (falls back to twine if unavailable)
- pyproject.toml for version management (PEP 621)
- Dev releases on every push to main
- Stable releases every Monday at 9:00 UTC
Instead of using API tokens, you can configure trusted publishing:
- Go to your PyPI project settings
- Add a new trusted publisher
- Configure the GitHub repository and workflow file
- Remove the
PYPI_TOKENsecret (no longer needed)
Your pyproject.toml should have a version field:
[project]
name = "my-package"
version = "0.1.0"
description = "My awesome package"
# ...Or if using Poetry:
[tool.poetry]
name = "my-package"
version = "0.1.0"
# ...| Secret | Description | Required |
|---|---|---|
PYPI_TOKEN |
PyPI API token | No (if using trusted publishing) |