Publish Poetry Project
Set up release automation for Poetry projects using one build job and separate publish jobs for GitHub Releases and PyPI.
Before editing:
- Read
pyproject.tomlto confirm the project name, build backend, console scripts, and any packaged resource includes. - Inspect the repository for existing GitHub Actions workflows and release documentation.
- Check whether the package needs package-data fixes before a release workflow is useful.
When implementing the workflow:
- Start from templates/workflow.yml.tmpl instead of drafting the GitHub Actions workflow from scratch.
- Render the template into a
.github/workflows/*.ymlworkflow with scripts/render_template.py, passing template values such asworkflow_name,tag_pattern,artifact_name, andpypi_environment. Example:python3 scripts/render_template.py templates/workflow.yml.tmpl workflow_name=Release 'tag_pattern=v*' artifact_name=python-package pypi_environment=pypi
When updating project files:
- Fix any broken
tool.poetry.includepackage-data paths that would make the build incomplete. - Keep
pyproject.tomlaligned with the workflow assumptions. - Update
README.mdwith a short release section that explains local build checks, tag-based publishing, and any PyPI trusted-publisher requirement.
Validation steps:
- Re-read the rendered workflow file for trigger, container image, artifact, and permission correctness.
- Confirm that the rendered workflow still matches the structure in templates/workflow.yml.tmpl unless the project needed a deliberate deviation.
- Run
poetry buildlocally when possible. - Call out any remaining manual setup, especially PyPI trusted publisher configuration and required GitHub permissions.
Read references/checklist.md before substantial publishing changes.