Skip to content

Latest commit

 

History

History
162 lines (117 loc) · 7.96 KB

RELEASING.md

File metadata and controls

162 lines (117 loc) · 7.96 KB

Releasing noderings-python

How a release gets from this repository to PyPI. Part 1 is done once; part 2 is every release.

Publishing uses PyPI trusted publishing: the release workflow proves to PyPI that it runs in this repository, and PyPI accepts the upload without any token stored on GitHub.

Part 1: one-time setup

Do these in order. Steps 1–3 need an owner of the noderings GitHub organization; step 4 needs a PyPI account.

1. Make the repository public

PyPI shows the repository as the project's homepage and links to the README, CHANGELOG and issues, which 404 while it is private. CodeQL and OpenSSF Scorecard also skip private repositories.

GitHub → noderings/noderings-python → Settings → General → Danger Zone → Change visibility → Make public.

Before you do: the repository holds no secrets (tokens are only read from the environment), and api/openapi.json is the same public file served at https://api.noderings.com/v1/openapi.json.

2. Create the pypi environment

The release job only gets permission to publish inside this environment, so it is also where you put an approval gate.

Settings → Environments → New environment → name pypi → Configure environment:

  • Required reviewers: add yourself. Each release then waits for your click in the Actions tab before anything is uploaded.
  • Deployment branches and tags: choose Selected branches and tags → Add deployment branch or tag rule → type Tag, pattern v*. Only release tags can then publish.

3. Protect main and the release tags (recommended)

  • Settings → Rules → Rulesets → New branch ruleset: target main; turn on Require a pull request before merging and Require status checks to pass (pick the Test, Lint and types, Generated code is up to date and Build and check the package checks); turn on Block force pushes. Add yourself (or the admin role) to the bypass list if you push small fixes directly.
  • New tag ruleset: target v*; turn on Restrict creations, Restrict updates and Restrict deletions, with the admin role in the bypass list. Then only admins can make a release tag.

4. Add the pending publisher on PyPI

The project noderings does not exist on PyPI yet. A pending publisher reserves the name for this workflow; the first release creates the project.

  1. Sign in at https://pypi.org (create an account if needed, and turn on two-factor authentication; PyPI requires it).

  2. Your account → Publishing (https://pypi.org/manage/account/publishing/).

  3. Under Add a new pending publisher, choose GitHub and fill in exactly:

    Field Value
    PyPI Project Name noderings
    Owner noderings
    Repository name noderings-python
    Workflow name release.yml
    Environment name pypi
  4. Add.

A pending publisher does not reserve the name forever: if someone else uploads a project called noderings first, it is gone. Do the first release soon after this step.

After the first release, the project page's Manage → Publishing shows the same publisher as active. Add the other NodeRings maintainers under Manage → Collaborators as owners, so the project never depends on one account.

5. Secrets for the nightly live tests (optional, recommended)

The live workflow runs the tests against the production API every night and skips itself when the token is missing. Settings → Secrets and variables → Actions:

Kind Name Value
Secret NODERINGS_TOKEN A service account token, ideally a dedicated account. It needs: SSH keys, DNS zones and records, firewall rulesets, cloud-init user data (create, read, delete); read on the organization, marketplace and metadata; and, for the billed run, virtual machines and snapshots.
Variable NODERINGS_TEST_ZONE_ID A DNS zone the tests may add and remove sdk-* records in (optional)
Variable NODERINGS_TEST_PLAN_ID For the billed VM test: a usage-billed (hourly) plan, for example 81dea236-1453-484c-aaf2-564a30aa353b (SC-GC-1C-1G-20, Ashburn)
Variable NODERINGS_TEST_REGION_ID That plan's region, 506ab941-39ff-4dea-9869-b853284b39a5 (Ashburn)

The nightly run never creates a virtual machine. To run the billed test, start Actions → live → Run workflow and tick billed. It costs a fraction of a cent on a usage-billed plan.

Check the setup

Part 2: every release

1. Prepare the release in a pull request

  1. Pick the version. While it is 0.x: a new minor (0.2.0) for new features or for renamed or removed fields; a patch (0.1.1) for fixes only.
  2. In src/noderings/_version.py, set __version__ = "0.2.0".
  3. In CHANGELOG.md, move the Unreleased entries under a new ## [0.2.0] - YYYY-MM-DD heading and update the compare links at the bottom. Call out anything that breaks existing code (a renamed field, a removed method).
  4. Open the pull request, wait for CI, merge.

For the first release, 0.1.0, the version and changelog are already set; skip to step 2.

2. Tag

From an up-to-date main:

git checkout main && git pull
git tag -a v0.2.0 -m v0.2.0
git push origin v0.2.0

The tag must be v plus exactly the version in _version.py; the workflow checks it and stops otherwise.

3. Approve and watch

Actions → release runs three jobs:

  1. build: runs the tests, checks the tag against the version, builds the wheel and sdist.
  2. pypi: waits for your approval (the environment's required reviewer), then uploads with trusted publishing. Click Review deployments → pypi → Approve and deploy.
  3. github: creates the GitHub release with generated notes and the built files attached.

4. Check it

python3 -m venv /tmp/nr && /tmp/nr/bin/pip install noderings==0.2.0
/tmp/nr/bin/python -c "import noderings; print(noderings.__version__, len(noderings.models.__all__))"

Then check https://pypi.org/project/noderings/: the version, the README, and the Verified details (the repository and workflow) in the sidebar.

If something goes wrong

Problem Fix
invalid-publisher or "no corresponding publisher" in the pypi job A field in the PyPI publisher does not match. They are case-sensitive; check the owner, repository, workflow file name (release.yml, not the workflow's display name) and environment (pypi).
"The tag matches the package version" fails The tag and _version.py differ. Delete the tag (git push --delete origin v0.2.0, git tag -d v0.2.0), fix the version in a pull request, tag again.
The pypi job waits forever It is waiting for approval: Review deployments on the run page.
"File already exists" PyPI never accepts the same version twice, even after deleting it. Release the next patch version.
A bad release is out On PyPI, Manage → Releases → Options → Yank the version (installs that pin it still work; new installs skip it), then release a fixed patch.
The tests fail in the build job Nothing was published. Fix on main, delete and re-create the tag.

How it fits together

File Role
.github/workflows/release.yml Runs on v* tags: build, publish to PyPI (trusted publishing), GitHub release
.github/workflows/ci.yml Tests on Python 3.10–3.14, lint, types, generated-code check, package build
.github/workflows/live.yml Nightly tests against the production API
.github/workflows/spec-update.yml Weekly: regenerates from the published API description and opens a pull request
src/noderings/_version.py The version, read by the build (pyproject.toml) and sent in the User-Agent
CHANGELOG.md What changed in each release