Skip to content

The agent that grows with you

feat(release): dispatch Stable Release from the default branch

ethernet667e6639af61
diff --git a/.github/workflows/desktop-bundled-release.yml b/.github/workflows/desktop-bundled-release.yml
index e1b279c7723..83a6316df89 100644
--- a/.github/workflows/desktop-bundled-release.yml
+++ b/.github/workflows/desktop-bundled-release.yml
@@ -2406,6 +2406,7 @@ jobs:
timeout-minutes: 90
env:
RELEASE_TAG: ${{ inputs.tag }}
+ RELEASE_COMMIT: ${{ needs.validate.outputs.sha }}
HERMES_ARCHIVE_TAG: ${{ needs.validate.outputs.archive-tag }}
CANDIDATE_MANIFEST_SHA256: ${{ inputs.manifest-sha256 }}
CLOUDFLARE_R2_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_R2_ACCOUNT_ID }}
@@ -2434,6 +2435,7 @@ jobs:
timeout-minutes: 60
env:
RELEASE_TAG: ${{ inputs.tag }}
+ RELEASE_COMMIT: ${{ needs.validate.outputs.sha }}
HERMES_ARCHIVE_TAG: ${{ needs.validate.outputs.archive-tag }}
CANDIDATE_MANIFEST_SHA256: ${{ inputs.manifest-sha256 }}
CLOUDFLARE_R2_PUBLIC_URL: ${{ vars.CLOUDFLARE_R2_PUBLIC_URL }}
diff --git a/scripts/bundles/release_artifacts.py b/scripts/bundles/release_artifacts.py
index 7a89af69888..bdc2d0f16d5 100644
--- a/scripts/bundles/release_artifacts.py
+++ b/scripts/bundles/release_artifacts.py
@@ -387,7 +387,8 @@ def main(argv: list[str] | None = None) -> None:
parser.add_argument("--tag", default=os.environ.get("RELEASE_TAG"))
parser.add_argument("--archive", default=os.environ.get("HERMES_ARCHIVE_TAG"),
help="Attempt ref the release archive is keyed under when the payload tag is plain vX.Y.Z")
- parser.add_argument("--commit", default=os.environ.get("GITHUB_SHA"))
+ # A stable run dispatches from the default branch, so GITHUB_SHA is not the admitted claim commit.
+ parser.add_argument("--commit", default=os.environ.get("RELEASE_COMMIT") or os.environ.get("GITHUB_SHA"))
parser.add_argument("--public-base", default=os.environ.get("CLOUDFLARE_R2_PUBLIC_URL"))
parser.add_argument("--release-epoch", type=int, default=os.environ.get("HERMES_RELEASE_EPOCH"))
parser.add_argument("--store-only", action="store_true")
diff --git a/scripts/release.py b/scripts/release.py
index 453691816b4..b701d807ca9 100755
--- a/scripts/release.py
+++ b/scripts/release.py
@@ -67,17 +67,16 @@ def list_remotes() -> list[str]:
def dispatch_desktop_build(tag: str, gh_repo: str | None) -> bool:
"""Dispatch the release pipeline after its draft exists.
- Stable workflows run on the tag so all reusable checks see the same
- commit. Their gate owns artifact publication and channel promotion.
- Canary builds keep default-branch workflow/cache scope and tagged inputs.
- Explicit dispatch also works for tags created by GITHUB_TOKEN.
+ Both channels run the default-branch workflow with the tag as an input, so
+ caches share one scope and scripts come from main. A stable run resolves its
+ claim tag to the commit under test. Its gate owns artifact publication and
+ channel promotion. Explicit dispatch also works for tags created by GITHUB_TOKEN.
"""
canary = _CANARY_TAG_RE.fullmatch(tag) is not None
if not canary and not STABLE_TAG_RE.fullmatch(tag):
raise ValueError("Expected an exact stable or canary release tag")
workflow = "desktop-bundled-release.yml" if canary else "stable-release.yml"
- cmd = ["gh", "workflow", "run", workflow, "--ref", "main" if canary else tag,
- "-f", f"tag={tag}"]
+ cmd = ["gh", "workflow", "run", workflow, "--ref", "main", "-f", f"tag={tag}"]
if canary:
cmd += ["-f", "upload_release=true"]
if gh_repo:
@@ -88,7 +87,7 @@ def dispatch_desktop_build(tag: str, gh_repo: str | None) -> bool:
print(f" Start it manually: {' '.join(cmd)}")
return False
- dispatch_ref = (_default_branch(gh_repo) or "main") if canary else tag
+ dispatch_ref = _default_branch(gh_repo) or "main"
cmd[cmd.index("--ref") + 1] = dispatch_ref
result = subprocess.run(
diff --git a/scripts/releases/channel_releases.py b/scripts/releases/channel_releases.py
index e2e83a67536..b579161a941 100644
--- a/scripts/releases/channel_releases.py
+++ b/scripts/releases/channel_releases.py
@@ -169,9 +169,8 @@ def admit_transaction(policy: str, env: dict, *, require_published: bool = False
default = ""
if policy == "stable-release":
default = run(["gh", "api", f"repos/{repository}", "--jq", ".default_branch"])
- claim_tag = env.get("RELEASE_CLAIM_TAG", "")
expected = {
- f"{repository}/.github/workflows/stable-release.yml@refs/tags/{claim_tag}",
+ f"{repository}/.github/workflows/stable-release.yml@refs/heads/{default}",
f"{repository}/.github/workflows/stable-release-publication.yml@refs/heads/{default}",
}
if (env.get("GITHUB_EVENT_NAME") not in {"workflow_dispatch", "workflow_run", "schedule"}
diff --git a/scripts/releases/entrypoint.py b/scripts/releases/entrypoint.py
index bf358016af1..3aa135c8c55 100644
--- a/scripts/releases/entrypoint.py
+++ b/scripts/releases/entrypoint.py
@@ -16,7 +16,7 @@ import time
from collections.abc import Callable
from pathlib import Path
-from scripts.releases import optional_platforms
+from scripts.releases import optional_platforms, stable
from scripts.releases.draft_warning import draft_body
from scripts.releases.versioning import (
SEED, attempt_ref, derive_next_version, marker_ref, next_attempt,
@@ -117,17 +117,26 @@ def _outstanding_attempt(repo: Path, remote: str) -> tuple[str, int, str] | None
return outstanding[0] if outstanding else None
+RUN_FIELDS = "databaseId,url,headBranch,headSha,displayTitle,status"
+
+
+def _is_claim_run(row: dict, claim_tag: str, commit: str) -> bool:
+ return stable.is_claim_run(
+ title=row.get("displayTitle"), head_branch=row.get("headBranch"),
+ head_sha=row.get("headSha"), claim_tag=claim_tag, commit=commit)
+
+
def _attempt_run(execute, repository: str, ref: str, commit: str) -> dict | None:
"""The workflow run for ``ref`` at ``commit``, or None when none is listed."""
raw = execute([
- "gh", "run", "list", "--repo", repository, "--workflow", WORKFLOW,
- "--branch", ref, "--json", "databaseId,url,headBranch,headSha,status",
+ "gh", "run", "list", "--repo", repository, "--workflow", WORKFLOW, "--limit", "100",
+ "--json", RUN_FIELDS,
])
try:
rows = json.loads(raw or "[]")
except json.JSONDecodeError:
return None
- return next((row for row in rows if isinstance(row, dict) and row.get("headSha") == commit
+ return next((row for row in rows if isinstance(row, dict) and _is_claim_run(row, ref, commit)
and row.get("url") and row.get("databaseId") is not None), None)
@@ -332,7 +341,7 @@ def release(commit: str, *, bump: str, repo: Path, remote: str, repository: str,
finally:
os.unlink(file.name)
execute([
- "gh", "workflow", "run", WORKFLOW, "--ref", tag, "--repo", repository,
+ "gh", "workflow", "run", WORKFLOW, "--ref", stable.CONTROLLER_BRANCH, "--repo", repository,
"--raw-field", f"tag={tag}",
])
run_url = _await_run(execute, repository, tag, wait=run_wait, sleep=sleep)
@@ -354,8 +363,8 @@ def _await_run(execute, repository: str, tag: str, *, wait: float, sleep) -> str
polls = int(wait // RUN_POLL_SECONDS)
for poll in range(polls + 1):
run_url = _dispatched_run(execute([
- "gh", "run", "list", "--repo", repository, "--workflow", WORKFLOW,
- "--branch", tag, "--json", "databaseId,url,headBranch,status",
+ "gh", "run", "list", "--repo", repository, "--workflow", WORKFLOW, "--limit", "100",
+ "--json", RUN_FIELDS,
]), tag)
if run_url or poll == polls:
return run_url
@@ -369,7 +378,8 @@ def _dispatched_run(raw: str, tag: str) -> str:
rows = json.loads(raw or "[]")
except json.JSONDecodeError:
return ""
- matched = [row for row in rows if isinstance(row, dict) and row.get("headBranch") == tag and row.get("url")]
+ matched = [row for row in rows if isinstance(row, dict) and row.get("url")
+ and row.get("displayTitle") == stable.claim_run_title(tag)]
if len(matched) != 1:
return ""
return str(matched[0]["url"])
@@ -442,13 +452,13 @@ def publish(version: str, *, repository: str, dispatch, inspect=None, head_versi
return {"requested": tag, "version": version, "repository": repository}
-def _in_progress_runs(inspect, repository: str, tag: str) -> list[dict]:
+def _in_progress_runs(inspect, repository: str, tag: str, commit: str) -> list[dict]:
"""Release runs of ``tag`` that have not completed, as ``gh run list`` rows."""
rows = json.loads(inspect([
- "gh", "run", "list", "--repo", repository, "--workflow", WORKFLOW,
- "--branch", tag, "--json", "databaseId,url,status", "--limit", "100",
+ "gh", "run", "list", "--repo", repository, "--workflow", WORKFLOW, "--limit", "100",
+ "--json", RUN_FIELDS,
]) or "[]")
- return [row for row in rows if row["status"] != "completed"]
+ return [row for row in rows if row["status"] != "completed" and _is_claim_run(row, tag, commit)]
def _abandon_attempt(version: str, attempt: int, tag: str, *, repo: Path, remote: str,
@@ -458,7 +468,7 @@ def _abandon_attempt(version: str, attempt: int, tag: str, *, repo: Path, remote
draft = _release_view(tag, repository, inspect)
if draft is not None and draft.get("isDraft") is not True:
raise ReleaseRefused(f"{tag} is published and cannot be abandoned")
- for run in _in_progress_runs(inspect, repository, tag):
+ for run in _in_progress_runs(inspect, repository, tag, _claim_commit(repo, tag)):
execute(["gh", "run", "cancel", str(run["databaseId"]), "--repo", repository, "--force"])
cancelled.append(run["url"])
if draft is not None:
diff --git a/scripts/releases/sequencer.py b/scripts/releases/sequencer.py
index e439904ac9f..ef4100c3bdd 100644
--- a/scripts/releases/sequencer.py
+++ b/scripts/releases/sequencer.py
@@ -225,7 +225,7 @@ def _tag_message(tag: str, expected_object: str, run=output) -> dict:
def discover(repository: str, run=output) -> list[dict]:
"""Derive every stable claim state from remote refs and GitHub objects."""
- from scripts.releases.stable import tagger_epoch, validate_claim, validate_final
+ from scripts.releases.stable import is_claim_run, tagger_epoch, validate_claim, validate_final
log("Fetching stable receipt tags, attempt refs and abandon markers from origin")
run([
@@ -309,8 +309,9 @@ def discover(repository: str, run=output) -> list[dict]:
or release.get("draft") is not True
or release.get("prerelease") is not False):
raise ValueError(f"{claim_tag} draft state is invalid")
- matching_runs = [row for row in workflow_runs
- if row.get("head_branch") == claim_tag and row.get("head_sha") == commit]
+ matching_runs = [row for row in workflow_runs if is_claim_run(
+ title=row.get("display_title"), head_branch=row.get("head_branch"),
+ head_sha=row.get("head_sha"), claim_tag=claim_tag, commit=commit)]
state, retry = classify_runs(
matching_runs,
claimed_at=datetime.fromtimestamp(claim_epoch, tz=UTC),
diff --git a/scripts/releases/stable.py b/scripts/releases/stable.py
index 11f92a7fb39..6d4b6d14b9b 100644
--- a/scripts/releases/stable.py
+++ b/scripts/releases/stable.py
@@ -503,13 +503,42 @@ def tagger_epoch(tag_object: str, run=output) -> int:
return epoch
+CONTROLLER_BRANCH = "main"
+CONTROLLER_REF = f"refs/heads/{CONTROLLER_BRANCH}"
+CONTROLLER_WORKFLOW = "stable-release.yml"
+
+
+def claim_run_title(claim_tag: str) -> str:
+ """The run-name stable-release.yml sets. Every run is on the default branch, so this names the claim."""
+ return f"Stable release {claim_tag}"
+
+
+def is_claim_run(*, title: str | None, head_branch: str | None, head_sha: str | None,
+ claim_tag: str, commit: str) -> bool:
+ """A Stable Release run for this claim. Runs started before the controller moved sat on the tag."""
+ return title == claim_run_title(claim_tag) or (head_branch == claim_tag and head_sha == commit)
+
+
+def check_controller(env: dict) -> None:
+ """Require the default-branch dispatch of Stable Release.
+
+ Reusable workflows keep the top-level caller's identity, so the same check holds
+ inside every called workflow. The commit under test comes from the claim tag, not
+ from GITHUB_SHA, which is the default branch tip here.
+ """
+ repository = env.get("GITHUB_REPOSITORY", "")
+ expected = f"{repository}/.github/workflows/{CONTROLLER_WORKFLOW}@{CONTROLLER_REF}"
+ if (not repository or env.get("GITHUB_EVENT_NAME") != "workflow_dispatch"
+ or env.get("GITHUB_REF") != CONTROLLER_REF or env.get("GITHUB_WORKFLOW_REF") != expected):
+ raise ValueError("Stable release must run from the default-branch controller workflow")
+
+
def check_claim(env: dict, run=output) -> dict:
"""Bind the run to one remote annotated claim object and its commit."""
- claim_tag, commit = env.get("RELEASE_CLAIM_TAG"), env.get("GITHUB_SHA")
- if not isinstance(claim_tag, str) or env.get("GITHUB_REF") != f"refs/tags/{claim_tag}":
- raise ValueError("Stable release must run on its exact claim ref")
- if not isinstance(commit, str) or not SHA.fullmatch(commit):
- raise ValueError("Stable claim needs an exact commit")
+ claim_tag = env.get("RELEASE_CLAIM_TAG")
+ if not isinstance(claim_tag, str) or not claim_tag:
+ raise ValueError("Stable release needs a claim tag")
+ check_controller(env)
claim_ref = f"refs/tags/{claim_tag}"
local_object = run(["git", "rev-parse", claim_ref])
local_commit = run(["git", "rev-parse", f"{claim_ref}^{{commit}}"])
@@ -521,10 +550,12 @@ def check_claim(env: dict, run=output) -> dict:
remote_object = remote.get(claim_ref)
remote_commit = remote.get(f"{claim_ref}^{{}}")
expected_object = env.get("RELEASE_CLAIM_OBJECT")
- if (local_commit != commit or remote_commit != commit or remote_object != local_object
- or (expected_object and remote_object != expected_object)
- or run(["git", "rev-parse", "HEAD"]) != commit):
- raise ValueError("Stable claim tag or checkout moved")
+ commit = local_commit
+ if not SHA.fullmatch(commit):
+ raise ValueError("Stable claim needs an exact commit")
+ if (remote_commit != commit or remote_object != local_object
+ or (expected_object and remote_object != expected_object)):
+ raise ValueError("Stable claim tag moved")
run(["git", "fetch", "origin", "+refs/heads/main:refs/remotes/origin/main"])
def on_main(sha: str) -> bool:
diff --git a/tests/ci/test_desktop_release_tag_admission.py b/tests/ci/test_desktop_release_tag_admission.py
index 38bcc5992de..6b729ee15f6 100644
--- a/tests/ci/test_desktop_release_tag_admission.py
+++ b/tests/ci/test_desktop_release_tag_admission.py
@@ -180,8 +180,12 @@ def _run_admission(clone: Path, tag: str, claim_tag: str) -> subprocess.Complete
RELEASE_CLAIM_OBJECT=_git("rev-parse", f"refs/tags/{claim_tag}", cwd=clone),
GITHUB_OUTPUT=str(gh_output),
RELEASE_PHASE="candidate",
- GITHUB_REF=f"refs/tags/{claim_tag}",
- GITHUB_SHA=_git("rev-parse", "HEAD", cwd=clone),
+ # Stable runs from the default branch; GITHUB_SHA is not the claim commit.
+ GITHUB_REPOSITORY="example/hermes-agent",
+ GITHUB_EVENT_NAME="workflow_dispatch",
+ GITHUB_REF="refs/heads/main",
+ GITHUB_WORKFLOW_REF="example/hermes-agent/.github/workflows/stable-release.yml@refs/heads/main",
+ GITHUB_SHA="e" * 40,
PYTHONPATH=str(_REPO),
)
return subprocess.run(
diff --git a/tests/scripts/test_release_canary_git.py b/tests/scripts/test_release_canary_git.py
index 9674dfa445f..a3aacb051fe 100644
--- a/tests/scripts/test_release_canary_git.py
+++ b/tests/scripts/test_release_canary_git.py
@@ -166,9 +166,11 @@ def test_stable_dispatch_and_failure(monkeypatch, tmp_path):
lambda command, **kwargs: calls.append(command)
or subprocess.CompletedProcess(command, 0, "", ""),
)
+ monkeypatch.setattr(release, "_default_branch", lambda _repo: "main")
assert release.dispatch_desktop_build("v1.2.3", "owner/repo")
+ # Stable dispatches the default-branch workflow, like canary; the tag is an input.
assert calls == [[
- "gh", "workflow", "run", "stable-release.yml", "--ref", "v1.2.3",
+ "gh", "workflow", "run", "stable-release.yml", "--ref", "main",
"-f", "tag=v1.2.3", "--repo", "owner/repo",
]]
with pytest.raises(ValueError):
diff --git a/tests/scripts/test_release_channels.py b/tests/scripts/test_release_channels.py
index 9ea55b82772..97d8cfba18e 100644
--- a/tests/scripts/test_release_channels.py
+++ b/tests/scripts/test_release_channels.py
@@ -564,7 +564,7 @@ def test_protected_transaction_refuses_custom_workflow_and_unpublished_release(m
"GITHUB_REPOSITORY": "example/hermes-agent", "RELEASE_TAG": attempt,
"RELEASE_COMMIT": commit, "RELEASE_CLAIM_TAG": attempt,
"RELEASE_CLAIM_OBJECT": "b" * 40,
- "GITHUB_WORKFLOW_REF": "example/hermes-agent/.github/workflows/stable-release.yml@refs/tags/" + attempt}
+ "GITHUB_WORKFLOW_REF": "example/hermes-agent/.github/workflows/stable-release.yml@refs/heads/main"}
published = [True]
def final_context(_env, run):
@@ -599,7 +599,7 @@ def test_stable_admission_requires_an_attempt_ref_release_tag(monkeypatch):
"GITHUB_REPOSITORY": "example/hermes-agent", "RELEASE_TAG": attempt,
"RELEASE_COMMIT": commit, "RELEASE_CLAIM_TAG": attempt,
"RELEASE_CLAIM_OBJECT": "b" * 40,
- "GITHUB_WORKFLOW_REF": "example/hermes-agent/.github/workflows/stable-release.yml@refs/tags/" + attempt}
+ "GITHUB_WORKFLOW_REF": "example/hermes-agent/.github/workflows/stable-release.yml@refs/heads/main"}
monkeypatch.setattr(channel_releases.stable, "final_context",
lambda _env, run: ("v1.2.3", commit, {}))
diff --git a/tests/scripts/test_release_entrypoint.py b/tests/scripts/test_release_entrypoint.py
index 3abd4643163..78a1188bef8 100644
--- a/tests/scripts/test_release_entrypoint.py
+++ b/tests/scripts/test_release_entrypoint.py
@@ -88,7 +88,8 @@ def test_release_claims_the_first_attempt_creates_a_draft_and_dispatches(source)
calls.append(command)
if command[:3] == ["gh", "run", "list"]:
return json.dumps([{"databaseId": 7, "url": "https://github.com/example/hermes-agent/actions/runs/7",
- "headBranch": "rc.1-v0.21.5", "status": "queued"}])
+ "headBranch": "main", "displayTitle": "Stable release rc.1-v0.21.5",
+ "status": "queued"}])
if command[:3] == ["gh", "release", "create"]:
return "https://github.com/example/hermes-agent/releases/tag/untagged-0123abcd\n"
return ""
@@ -124,10 +125,11 @@ def test_release_claims_the_first_attempt_creates_a_draft_and_dispatches(source)
assert "--notes-file" in create
assert create[-2:] == ["--title", "Hermes Agent v0.21.5"]
assert calls[1:] == [
- ["gh", "workflow", "run", "stable-release.yml", "--ref", "rc.1-v0.21.5",
+ # Stable dispatches the default-branch workflow. The tag is an input.
+ ["gh", "workflow", "run", "stable-release.yml", "--ref", "main",
"--repo", "example/hermes-agent", "--raw-field", "tag=rc.1-v0.21.5"],
["gh", "run", "list", "--repo", "example/hermes-agent", "--workflow", "stable-release.yml",
- "--branch", "rc.1-v0.21.5", "--json", "databaseId,url,headBranch,status"],
+ "--limit", "100", "--json", "databaseId,url,headBranch,headSha,displayTitle,status"],
]
assert result["run_url"] == "https://github.com/example/hermes-agent/actions/runs/7"
# The claim push names the claim ref and nothing else.
@@ -181,7 +183,8 @@ def test_an_unlisted_run_points_at_the_workflow_page():
])
def test_release_looks_for_the_dispatched_run_only_within_its_wait(source, lists_on, wait, run_url, naps):
listed = json.dumps([{"databaseId": 7, "url": "https://github.com/example/hermes-agent/actions/runs/7",
- "headBranch": "rc.1-v0.21.5", "status": "queued"}])
+ "headBranch": "main", "displayTitle": "Stable release rc.1-v0.21.5",
+ "status": "queued"}])
lists, slept = [], []
def execute(command):
@@ -372,13 +375,16 @@ def test_refusal_names_the_run_and_both_ways_out(source, capsys):
def execute(command):
assert command == ["gh", "run", "list", "--repo", "example/hermes-agent", "--workflow",
- "stable-release.yml", "--branch", "rc.1-v0.21.5",
- "--json", "databaseId,url,headBranch,headSha,status"]
+ "stable-release.yml", "--limit", "100",
+ "--json", "databaseId,url,headBranch,headSha,displayTitle,status"]
+ # Newest first. Run 98 belongs to another claim, so it must not be named.
return json.dumps([
- {"databaseId": 98, "url": "https://github.com/example/hermes-agent/actions/runs/98",
- "headBranch": "rc.1-v0.21.5", "headSha": "0" * 40, "status": "completed"},
{"databaseId": 99, "url": "https://github.com/example/hermes-agent/actions/runs/99",
- "headBranch": "rc.1-v0.21.5", "headSha": blocked, "status": "completed"},
+ "headBranch": "main", "headSha": "f" * 40,
+ "displayTitle": "Stable release rc.1-v0.21.5", "status": "completed"},
+ {"databaseId": 98, "url": "https://github.com/example/hermes-agent/actions/runs/98",
+ "headBranch": "main", "headSha": "f" * 40,
+ "displayTitle": "Stable release rc.1-v0.21.4", "status": "completed"},
])
with pytest.raises(ReleaseRefused):
@@ -450,7 +456,8 @@ def test_release_draft_lists_the_commits_since_the_stable_base(source, published
seen["body"] = file.read()
if command[:3] == ["gh", "run", "list"]:
return json.dumps([{"databaseId": 7, "url": "https://github.com/example/hermes-agent/actions/runs/7",
- "headBranch": "rc.1-v0.21.5", "status": "queued"}])
+ "headBranch": "main", "displayTitle": "Stable release rc.1-v0.21.5",
+ "status": "queued"}])
return ""
result = _release(source, commit, execute=execute, published=published)
@@ -653,7 +660,8 @@ def _abandon(repo, version, *, drafts=None, runs=None, calls=None, execute=None)
def inspect(command):
if command[1] == "run":
- return json.dumps(list((runs or {}).get(command[command.index("--branch") + 1], [])))
+ return json.dumps([{**row, "displayTitle": f"Stable release {tag}"}
+ for tag, rows in (runs or {}).items() for row in rows])
draft = (drafts or {}).get(command[3])
if draft is None:
raise ReleaseRefused("release not found")
@@ -710,7 +718,8 @@ def test_abandon_that_cannot_cancel_a_run_writes_no_marker_so_it_can_be_retried(
from scripts.releases.entrypoint import ReleaseRefused, abandon
_claim(source, "0.21.5", git(source, "rev-parse", "HEAD"))
- run = {"databaseId": 11, "url": "https://example.test/runs/11", "status": "in_progress"}
+ run = {"databaseId": 11, "url": "https://example.test/runs/11", "status": "in_progress",
+ "displayTitle": "Stable release rc.1-v0.21.5"}
def refuse(_command):
raise ReleaseRefused("HTTP 403")
diff --git a/tests/scripts/test_stable_release.py b/tests/scripts/test_stable_release.py
index b07e0694533..a0dcfa9f113 100644
--- a/tests/scripts/test_stable_release.py
+++ b/tests/scripts/test_stable_release.py
@@ -362,12 +362,52 @@ def test_manifest_origin_checks_with_real_https(https_origin):
assert server.requests == []
+# Stable runs from the default branch. GITHUB_SHA is main's tip, never the claim commit.
+CONTROLLER_ENV = {
+ "GITHUB_REPOSITORY": "example/hermes-agent",
+ "GITHUB_EVENT_NAME": "workflow_dispatch",
+ "GITHUB_REF": "refs/heads/main",
+ "GITHUB_WORKFLOW_REF": "example/hermes-agent/.github/workflows/stable-release.yml@refs/heads/main",
+ "GITHUB_SHA": "e" * 40,
+}
+
+
+def test_a_claim_run_is_found_by_its_run_name_on_main_or_by_its_tag_branch():
+ from scripts.releases.stable import claim_run_title, is_claim_run
+
+ tag, commit = "rc.1-v1.2.3", "a" * 40
+ assert claim_run_title(tag) == "Stable release rc.1-v1.2.3"
+
+ def match(**row):
+ return is_claim_run(**{"title": None, "head_branch": "main", "head_sha": "e" * 40, **row},
+ claim_tag=tag, commit=commit)
+
+ assert match(title="Stable release rc.1-v1.2.3")
+ # Runs started before the controller moved sat on the tag at the claim commit.
+ assert match(head_branch=tag, head_sha=commit)
+ assert not match(title="Stable release rc.2-v1.2.3")
+ assert not match(head_branch=tag, head_sha="e" * 40)
+ assert not match()
+
+
+def test_claim_must_run_from_the_default_branch_controller():
+ base = {**CONTROLLER_ENV, "RELEASE_CLAIM_TAG": "rc.1-v1.2.3"}
+ for wrong in (
+ {"GITHUB_REF": "refs/tags/rc.1-v1.2.3"},
+ {"GITHUB_REF": "refs/heads/feature"},
+ {"GITHUB_EVENT_NAME": "workflow_run"},
+ {"GITHUB_WORKFLOW_REF": "example/hermes-agent/.github/workflows/other.yml@refs/heads/main"},
+ {"GITHUB_WORKFLOW_REF": "example/hermes-agent/.github/workflows/stable-release.yml@refs/tags/rc.1-v1.2.3"},
+ ):
+ with pytest.raises(ValueError, match="default-branch controller"):
+ check_claim({**base, **wrong}, lambda argv: pytest.fail("no git before the controller check"))
+
+
def test_claim_object_movement_and_lightweight_tags_fail_closed(tmp_path, monkeypatch):
commit = "a" * 40
claim_object = "b" * 40
ref = "refs/tags/rc.1-v1.2.3"
- env = {"RELEASE_CLAIM_TAG": "rc.1-v1.2.3", "RELEASE_CLAIM_OBJECT": claim_object,
- "GITHUB_SHA": commit, "GITHUB_REF": ref}
+ env = {**CONTROLLER_ENV, "RELEASE_CLAIM_TAG": "rc.1-v1.2.3", "RELEASE_CLAIM_OBJECT": claim_object}
message = {"schema": 1, "version": "1.2.3", "attempt": 1, "commit": commit,
"autopublish": False, "skipBundles": False, "skipTests": False,
"claimEpoch": 1_790_000_000}
@@ -397,7 +437,7 @@ def test_claim_object_movement_and_lightweight_tags_fail_closed(tmp_path, monkey
for wrong in ({**message, "attempt": 2}, {k: v for k, v in message.items() if k != "attempt"}):
with pytest.raises(ValueError, match="metadata is invalid"):
check_claim(env, lambda argv, wrong=wrong: json.dumps(wrong) if argv[1] == "tag" else git(argv))
- with pytest.raises(ValueError, match="moved"):
+ with pytest.raises(ValueError, match="tag moved"):
check_claim(env, lambda argv: f"{'c' * 40}\t{ref}\n{commit}\t{ref}^{{}}"
if argv[1] == "ls-remote" else git(argv))
with pytest.raises(ValueError, match="annotated"):
@@ -426,7 +466,7 @@ def test_claim_object_movement_and_lightweight_tags_fail_closed(tmp_path, monkey
env={**os.environ, "GIT_COMMITTER_DATE": "@1790000000 +0000"},
)
subprocess.run(["git", "push", "origin", "main", "rc.1-v1.2.3"], check=True, capture_output=True)
- env.update({"GITHUB_SHA": actual, "RELEASE_CLAIM_OBJECT": subprocess.check_output(
+ env.update({"RELEASE_CLAIM_OBJECT": subprocess.check_output(
["git", "rev-parse", ref], text=True, encoding="utf-8").strip()})
claim = check_claim(env)
assert claim["commit"] == actual
@@ -581,7 +621,7 @@ def test_complete_writes_no_final_tag_and_leaves_the_draft_on_the_attempt_ref(tm
monkeypatch.chdir(tmp_path / "repo")
stable.complete({
"RELEASE_CLAIM_TAG": "rc.1-v1.2.3", "RELEASE_CLAIM_OBJECT": tag_object,
- "GITHUB_SHA": commit, "GITHUB_REF": "refs/tags/rc.1-v1.2.3",
+ **CONTROLLER_ENV,
"RELEASE_TAG": "v1.2.3", "CANDIDATE_MANIFEST_SHA256": "c" * 64,
"CLOUDFLARE_R2_PUBLIC_URL": BASE,
})
diff --git a/website/docs/developer-guide/stable-releases.md b/website/docs/developer-guide/stable-releases.md
index d58a7181a36..c2be0717b47 100644
--- a/website/docs/developer-guide/stable-releases.md
+++ b/website/docs/developer-guide/stable-releases.md
@@ -19,15 +19,20 @@ files on `main`.
version line. A cut whose next version already has a final `vX.Y.Z` tag is
refused until that publication finishes.
2. Push an annotated `rc.<N>-vX.Y.Z` attempt ref atomically, create one
- non-prerelease GitHub draft on it, and dispatch `Stable Release` on that exact
- ref. The attempt number comes from the existing attempt refs of that version.
+ non-prerelease GitHub draft on it, and dispatch `Stable Release` from the
+ default branch with that ref as its `tag` input. The attempt number comes from the existing attempt refs of that version.
The claim message binds its commit, attempt number, autopublish policy,
`skipBundles`, `skipTests`, `includeMacosIntel` and `includeTermux` flags, and
one monotonically allocated epoch. That epoch is the release date and native
packaging clock for every matrix leg and retry. One outstanding attempt, of
any version, blocks a new `release`.
-3. Admit the exact remote annotated tag-object SHA, peeled commit, `GITHUB_REF`,
- `GITHUB_SHA`, checked-out `HEAD`, and ancestry on `origin/main`.
+3. Admit the exact remote annotated tag-object SHA, its peeled commit, and that
+ commit's ancestry on `origin/main`. The run itself must be the default-branch
+ dispatch of `Stable Release`. Its workflows and release scripts come from
+ `main`, so its Actions caches share one scope across attempts. `GITHUB_SHA` is
+ `main`'s tip, never the commit under test. Every lane that tests or builds the
+ payload is passed the admitted commit, and the commit-threading lint in
+ `tests/ci/test_stable_release_commit_threading.py` enforces that.
4. Run the whole source, Docker, Nix, PM bundle, install/update, Windows,
signed-package, and native-upgrade acceptance graph (plus macOS Intel and
Termux when the claim opted into them).
@@ -213,7 +218,7 @@ writes an `abandoned-rc.<N>-vX.Y.Z` marker ref, and keeps the attempt ref. The
marker is the record of abandonment; the attempt ref is never deleted. The
version is not spent, so the next cut is `rc.<N+1>-vX.Y.Z`.
-Do not manually dispatch `Stable Release` from a final tag. Recovery keeps the
+Do not manually dispatch `Stable Release` with a final tag. Recovery keeps the
original claim ref, object SHA, commit, draft database ID, autopublish policy,
and skip flags.