Skip to content

Latest commit

 

History

History
101 lines (81 loc) · 5.02 KB

RELEASING.md

File metadata and controls

101 lines (81 loc) · 5.02 KB

Releasing

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/.)

Once: set up Trusted Publishing

  1. Add a publisher on PyPI. The project python-wrap already exists, so go to https://pypi.org/manage/project/python-wrap/settings/publishing/ and add a GitHub publisher with exactly:

    Field Value
    Owner LitePy
    Repository name PythonWrap
    Workflow name release.yml
    Environment name pypi
  2. 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 name testpypi.

  3. Create the GitHub environments in the repository under Settings, Environments: pypi and testpypi. Under pypi, "Deployment branches and tags" must allow the main branch and v* tags. Add yourself as a required reviewer on pypi so every real upload waits for one click.

Every release

  1. Version. Set __version__ in src/python_wrap/__init__.py. It is the only place the version lives. Use PEP 440 spelling: 0.3.0rc1, 0.3.0.

  2. Changelog. Move the Unreleased entries under ## [<version>] - <date>. The GitHub release notes are taken from this section. Two checks before tagging:

    • No Unreleased entry 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.
  3. 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 pytest run includes the tests/e2e/ happy-path scenarios.

  4. Merge to main, after local checks and release-branch CI pass. The merge releases. When __version__ has no v<version> tag yet, release.yml runs 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 the pypi environment, 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.

  5. Pre-releases (a, b, rc) stop after TestPyPI. Merge one first to rehearse a big release; a version can never be reused on PyPI.

  6. No release. A merge that keeps an already-tagged version, or a .dev version, only builds. Pushing a v<version> tag by hand still releases it. workflow_dispatch only builds and verifies artifacts; it never uploads.

  7. 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
  8. Open the next cycle. Add an empty Unreleased section to the changelog and bump __version__ to the next .dev0.

If something goes wrong

  • 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.

Recovering the first 0.2.0 release

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.