How a version of python-wrap gets from this repository to PyPI.
Publishing uses PyPI Trusted Publishing from .github/workflows/release.yml. No API
token exists anywhere, and none should be created. (The old token-based publish.yml
was removed; revoke the token it used at https://pypi.org/manage/account/token/.)
-
Add a publisher on PyPI. The project
python-wrapalready exists, so go to https://pypi.org/manage/project/python-wrap/settings/publishing/ and add a GitHub publisher with exactly:Field Value Owner LitePyRepository name PythonWrapWorkflow name release.ymlEnvironment name pypi -
Add a pending publisher on TestPyPI. The project does not exist there yet, so use https://test.pypi.org/manage/account/publishing/ with the same values, project name
python-wrap, and environment nametestpypi. -
Create the GitHub environments in the repository under Settings, Environments:
pypiandtestpypi. Underpypi, "Deployment branches and tags" must allow themainbranch andv*tags. Add yourself as a required reviewer onpypiso every real upload waits for one click.
-
Version. Set
__version__insrc/python_wrap/__init__.py. It is the only place the version lives. Use PEP 440 spelling:0.3.0rc1,0.3.0. -
Changelog. Move the
Unreleasedentries under## [<version>] - <date>. The GitHub release notes are taken from this section. Two checks before tagging:- No
Unreleasedentry may describe code that is in the tag. Cut the section first. - A final release differs from its last beta only by fixes. New features need a new beta.
- No
-
Check locally.
uv run pytest uv run ruff check src tests scripts/check_installed.py uv run ruff format --check src tests scripts/check_installed.py uv run mypy uv run mkdocs build --strict uv build && uvx twine check --strict dist/* && rm -rf dist python scripts/smoke_wheel.py # wheel in a fresh venv: version, no deps, py.typed, CLIs python scripts/check_release.py --tag # duplicate changelog entries, empty Unreleased, classifier vs stability page
The default
pytestrun includes thetests/e2e/happy-path scenarios. -
Merge to
main, after local checks and release-branch CI pass. The merge releases. When__version__has nov<version>tag yet,release.ymlruns the full CI suite, builds, checks the wheel, uploads to TestPyPI and verifies the installed package. A final version then waits for your approval of thepypienvironment, uploads the same artifacts to PyPI with attestations and verifies an installation from PyPI. Last, it creates the tag and the GitHub release with the files attached. -
Pre-releases (
a,b,rc) stop after TestPyPI. Merge one first to rehearse a big release; a version can never be reused on PyPI. -
No release. A merge that keeps an already-tagged version, or a
.devversion, only builds. Pushing av<version>tag by hand still releases it.workflow_dispatchonly builds and verifies artifacts; it never uploads. -
Smoke-test from a fresh directory:
uv venv /tmp/python-wrap-smoke uv pip install --python /tmp/python-wrap-smoke --no-deps --index-url https://pypi.org/simple/ python-wrap==0.3.0 /tmp/python-wrap-smoke/bin/python -I scripts/check_installed.py 0.3.0
-
Open the next cycle. Add an empty
Unreleasedsection to the changelog and bump__version__to the next.dev0.
- The upload failed halfway. Re-run the failed job. TestPyPI uses
skip-existing. - A broken version reached PyPI. Yank it (PyPI, Manage, Release, Options, Yank) and release the fix under the next number.
The saved release notes record a failed upload (invalid-publisher) from an older
v0.2.0 tag. Do not rerun that old tag to publish the completed extras: a rerun uses
the old source and workflow. First confirm the current project release history on
both indexes and configure both trusted publishers above. A pending TestPyPI
publisher creates the project on its first successful workflow upload; there is no
separate empty-project creation step.
Merge the release changes with green CI before creating a new tag. If 0.2.0 has
already reached PyPI, use a new version. If it has not, either have a maintainer
explicitly replace the old tag with the reviewed commit, or choose a fresh version
and update __version__ and the changelog together. Do not rewrite a published tag
as part of routine release automation.
invalid-publisher means the index cannot match the workflow's OIDC identity to a
registered publisher. Check the owner (LitePy), repository (PythonWrap), workflow
filename (release.yml), environment (pypi or testpypi), and that the publisher
was registered on the correct index. PyPI and TestPyPI have separate accounts and
publisher configurations.