Publishing a GitHub Release triggers .github/workflows/publish.yml. Do not publish the release until CI has passed and the tag matches the version in pyproject.toml (for example, version 2.0.2 requires tag v2.0.2). Prereleases are intentionally blocked from production PyPI.
- In the GitHub repository, create an environment named exactly
pypi. - Add a deployment branch/tag rule that permits only release tags (recommended pattern:
v*). Add required reviewers where the repository plan supports them, and prevent administrators from bypassing the rule when appropriate. - Open https://pypi.org/manage/project/secure/settings/publishing/ and add a GitHub Actions trusted publisher with these exact values:
- PyPI project:
secure - Owner:
TypeError - Repository:
secure - Workflow name:
publish.yml - Environment name:
pypi
- PyPI project:
Do not create or store a PyPI API token. The publish job obtains a short-lived OIDC credential and keeps the publishing action's default package attestations enabled.
Run these commands from an activated development environment before publishing the GitHub Release:
python3 -m pytest -q
ruff check secure tests
ruff format --check secure tests
python3 -m build
python3 -m twine check dist/*
git diff --check- Merge reviewed changes into
main. - Update the package version in
pyproject.tomland refreshuv.lock. - Run the local checks and confirm CI succeeds on
main. - Create and publish a GitHub Release from the matching tag (for example,
v2.0.2). Publishing the GitHub Release starts the PyPI workflow. - Approve the
pypienvironment deployment if required. - Let GitHub Actions build, validate, and publish the artifacts.
- Verify the version appears at https://pypi.org/project/secure/.
- Install the released version in a clean environment and verify its metadata and import.
- For a security release, publish the corresponding advisory only after the patched package is available.
The workflow fails if the release tag does not exactly match the package version or if the tagged commit is not on main. PyPI rejects attempts to overwrite an existing release.