Skip to content

feat(release): scheduled release candidates, token-free publishing, automatic retries - #3190

Open
DeusData wants to merge 3 commits into
mainfrom
feat/scheduled-release-candidates
Open

DeusData wants to merge 3 commits into
mainfrom
feat/scheduled-release-candidates

Conversation

@DeusData

@DeusData DeusData commented Dec 4, 2026

Copy link
Copy Markdown
Owner

What this does

Automatic release candidates (vX.Y.Z-rc.N) twice a week, token-free registry publishing, and automatic retries of flaky release runs, while stable releases stay maintainer-dispatched and maintainer-approved.

  • One pipeline, two channels. release.yml gains a Monday/Thursday schedule and a plan job (scripts/ci/release-plan.py). A release candidate runs every gate a stable release runs (tests, VirusTotal candidate scan, smoke, soak, signing, provenance, SBOM, security, CodeQL, verify); only the publishing tail differs: GitHub pre-release, npm next, PyPI pre-release; no MCP Registry, no legacy ui-* aliases.
  • Version and environment come from the version's shape. Only vX.Y.Z and vX.Y.Z-rc.N exist. Only an -rc.N may publish from the unattended rc environment; everything else goes through release, which needs the maintainer's approval. Checked in plan, preflight and at the start of the publish job. RC numbers are one above the highest any of git tags, npm and PyPI holds, so a number is never reused.
  • No stored registry tokens. npm and PyPI are reached by OIDC trusted publishing only, from release.yml in the rc or release environment (both restricted to main). Packaging (package-registries) runs with no publish identity from a hash-pinned toolchain (the hatchling build backend now included, built with --no-isolation); publish-registries checks out nothing, holds only id-token, and only uploads.
  • Red runs are settled, never half-shipped. scripts/ci/rc-reconcile.py makes a draft public when npm or PyPI already serves it, deletes a draft nothing serves (after asking both registries for that exact version), never touches a published release, and never touches a stable. The pkg/go tag is pushed only after the un-draft, never forced.
  • Automatic retries (release-retry.yml, hourly, RELEASE_RETRY=off stops it): the failed jobs of the newest Release run, scheduled or dispatched, are rerun at most twice by a fail-closed policy (scripts/ci/release-retry-decide.py). Gates (VirusTotal, security, license, CodeQL, lint), publishing jobs, and a test step that failed on two or more legs or on two attempts are never retried. A green on retry ships with a "passed on retry" paragraph naming the flaky job. Every outcome is logged on one "Release run retries" issue.
  • PyPI wrapper fix: a release candidate installed from PyPI downloaded from v0.12.2rc1 (PEP 440 spelling), a release that never exists; it now uses the tag form v0.12.2-rc.1. The one RC ever published to PyPI (0.9.1rc1) could not install.

The schedule stays off until the repository variable RC_SCHEDULE is set to on.

CI scope

  • Gating: release.yml and release-retry.yml are not PR checks. Five new contract tests (seconds each) join scripts/test.sh.
  • Cost: when switched on, each RC is a full release run (2-6 h, macOS and Windows legs, 24 VirusTotal candidate uploads plus the shipped-file scan), at most twice a week, skipped when no shipped file changed. The retry controller is a ~20 s ubuntu job every hour.
  • Flake surface: RC runs meet the known Windows ARM64 soak flake; retries are bounded at two and never touch gates or publishing.
  • Trigger: Monday and Thursday 20:17 UTC (inert until RC_SCHEDULE=on), hourly retry pass (stop with RELEASE_RETRY=off); dispatch unchanged, except that an empty version now means "the next release candidate".

How it was verified

  • Real inputs, not only fixtures: the plan on the real tags and npm/PyPI version lists (12 scenarios; real RC numbering across 0.9.1-rc.1 / 0.9.1rc1); the retry policy replayed over the five real release runs of October (it retries the two single-leg Windows ARM64 soak failures, stops at the Security-audits gate and at the 12-leg smoke failure, and stops attempt 2 of that run because it failed identically to attempt 1, as the manual rerun did); a read-only dry run of reconcile and of the retry controller against the live repository; real PyPI wheels built from main and from the fix (v0.12.2rc1 before, v0.12.2-rc.1 after; GitHub has v0.9.1-rc.1, not v0.9.1rc1); the hash-pinned toolchain building sdist and wheel with --no-isolation in a linux/amd64 Python 3.12 container; npm pack producing the exact tarball name the publish job expects.
  • Every rule is pinned by a test that fails without it: 78 deliberate mutations across the five new contracts (plan 11, reconcile 14, retry policy 18, retry controller 11, workflow wiring 24), all caught.
  • Suites: all 13 affected contracts, the PyPI wrapper suite (49 tests), shellcheck, byte-compile. Local 3-OS ladder skipped: no C or platform code changed; PR CI is the gate.
  • Independent review of the branch (correctness and security); its five major and six minor findings are fixed in the third commit.

tests/test_release_gate_chain_contract.sh now also allows plan in the smoke/soak needs (they carry the planned version); build must still be a direct dependency.

Before merging

  1. Create the two npm trusted-publisher entries for codebase-memory-mcp (an entry must be validated by a publish within 48 h of creation): release.yml + environment rc (allow npm publish), and release.yml + environment release (allow npm publish and npm dist-tag). The PyPI publishers and both GitHub environments already exist.

After merging

  1. Dispatch one release candidate by hand (empty version): the end-to-end proof of OIDC publishing.
  2. Set RC_SCHEDULE=on.
  3. Once a stable release has also published through OIDC: delete NPM_TOKEN and PYPI_TOKEN, and switch npm publishing access to "disallow tokens".

The release pipeline stamps pyproject.toml with the tag's version
(0.12.2-rc.1). Packaging normalizes that to the PEP 440 form 0.12.2rc1 in
the installed metadata, and the wrapper built its download URL from the
metadata, asking for a v0.12.2rc1 release that never exists. The one
release candidate published to PyPI so far (0.9.1rc1) could therefore
never install: its wrapper requested v0.9.1rc1, while the release is
v0.9.1-rc.1.

Map the PEP 440 release-candidate form back to the tag it was built
from. Stable versions are unchanged. Verified on real wheels built with
the pinned hatchling: the wheel from main requests
.../download/v0.12.2rc1, the fixed one .../download/v0.12.2-rc.1.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
…ishing

release.yml now cuts release candidates (vX.Y.Z-rc.N) on a Monday and
Thursday schedule, or on demand by dispatching with an empty version.
They run every gate a stable release runs (tests, VirusTotal, smoke,
soak, signing, verify); only the publishing tail differs. Stable
releases stay maintainer-dispatched.

- plan (scripts/ci/release-plan.py) decides version and channel from
  git tags, the npm and PyPI version lists and the GitHub releases.
  Only vX.Y.Z and vX.Y.Z-rc.N are accepted (PEP 440 reads some suffixes,
  such as v1.0-1, as final releases, and the Go wrapper understands only
  -rc.N). The deployment environment follows the
  version's shape, so an unclear input lands in the approval gate. An
  RC number is one above the highest that any source holds, so a red
  run can never cause a number to be reused. A scheduled run skips when
  no shipped file changed, while the RC_SCHEDULE variable is off, or
  while another Release run is active; a dispatch then fails instead.
- npm and PyPI are reached by OIDC trusted publishing only, from the
  `release` environment (maintainer approval) or the `rc` environment
  (unattended, main only). NPM_TOKEN and PYPI_TOKEN are no longer
  referenced. npm is pinned to 11.21.3 (dist-tag under trusted
  publishing needs 11.21.0); PyPI uploads through
  pypa/gh-action-pypi-publish pinned by commit.
- The pkg/go tag is pushed after the un-draft, never forced, so Go never
  resolves a version whose release is still a draft. `replace` deletes
  only drafts. RC notes compare against the previous stable.
- reconcile (scripts/ci/rc-reconcile.py) settles what a red RC run left:
  a draft that npm or PyPI already serves is made public, a draft
  nothing serves is deleted with its tag, a published release is never
  touched.
- rc-retry.yml reruns a failed scheduled RC at most twice, by a
  fail-closed policy (scripts/ci/rc-retry-decide.py): gates, publishing
  jobs and a test step that failed on two or more legs are never
  retried. A green on retry is published with a "passed on retry" note
  naming the job. Outcomes are logged on one tracking issue. It runs on a
  schedule rather than workflow_run, which matches workflows by name and
  most likely does not fire for reruns started by the workflow token.

Contracts: test_release_plan, test_rc_reconcile, test_rc_retry_policy
and test_release_rc_flow pin these rules; each rule was checked to fail
its test when broken. test_release_gate_chain now also allows `plan` in
the smoke and soak needs, which carry the planned version; `build` must
still be a direct dependency.

The schedule stays off until RC_SCHEDULE is set to "on".

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
An independent review of the release-candidate flow found ways a rerun or
a cleanup could do the wrong thing. Each is fixed with a test that fails
without the fix:

- A rerun skips `plan`, so the retry controller reruns only the newest
  Release run and only while no other run is active. Release tags are
  pushed without --force, so a second run can never move another run's
  tag.
- Packaging is split from publishing. package-registries builds the npm
  tarball and the PyPI files with no publish identity, from a toolchain
  installed by hash; the hatchling build backend is now hash-pinned too
  and used with --no-isolation. publish-registries checks out nothing,
  holds only id-token, and only uploads.
- Moving npm `next` after a stable runs last and only warns on failure,
  so it can never leave `latest` pointing at a release still in draft.
- Reconcile creates and deletes tags through the REST API, so it no
  longer needs the tagged commit in a shallow checkout. It repairs a
  published RC above the newest stable that lacks its pkg/go tag,
  re-reads live state before every action, and asks npm and PyPI for the
  exact version before deleting a draft, since listings can lag.
- The retry controller is rewritten in Python with per-run error
  isolation. Only markers written by github-actions[bot] count. An
  attempt that fails the same way as the one before is not retried. A
  test leg's derived shard-completeness failure no longer blocks its
  infra retry, and the plan's network collection step is retryable.
- Smaller fixes: version digits are ASCII only; a stale RC_BASE_VERSION
  falls back to the newest stable + 1 patch with a warning; renames count
  on both ends of the changed-files diff; RC checksums no longer list the
  legacy ui-* aliases.

Retries now cover every Release run on main (scheduled and dispatched,
stable included) and run hourly; the RELEASE_RETRY variable set to "off"
stops them. Renamed accordingly: release-retry.yml,
release-retry-decide.py, release-retry.py, and the tracking issue
"Release run retries".

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant