Skip to content

The agent that grows with you

refactor(release): one canary-tag rule, imported from hermes_cli.update_channel

ethernetad53be782641
diff --git a/scripts/bundles/release_artifacts.py b/scripts/bundles/release_artifacts.py
index cc9be776373..cd4c929386e 100644
--- a/scripts/bundles/release_artifacts.py
+++ b/scripts/bundles/release_artifacts.py
@@ -250,8 +250,9 @@ def publish_canary_appinstaller(root: Path, *, tag: str, variant: str, bundle: P
identity: str, publisher: str, version: str, public_base: str) -> None:
"""Native SDK work is complete; verify its identity before writing a feed."""
from scripts.releases.r2 import put
+ from hermes_cli.update_channel import is_canary_tag
- if not re.fullmatch(r"v\d+\.\d+\.\d+-canary\.20\d{6}(?:\d{6})?", tag or ""):
+ if not is_canary_tag(tag):
raise ValueError("Only canary feeds publish directly; stable requires accepted candidates")
if variant not in ("bundled", "light"):
raise ValueError("Store and commit builds have no App Installer feed")
diff --git a/scripts/generate_icons.py b/scripts/generate_icons.py
index 6ebd2cdb62d..089dacaafde 100644
--- a/scripts/generate_icons.py
+++ b/scripts/generate_icons.py
@@ -506,8 +506,9 @@ def build_art(source: Path) -> tuple[IconArt, IconArt]:
if not re.fullmatch(r"[a-f0-9]{40}", commit):
raise ValueError("HERMES_BUILD_COMMIT requires an exact full 40-character SHA")
return art, IconArt(source, colors=("#e34850", "#4a1117"), commit=commit)
- # Match the desktop/feed identity, including historical date-only tags.
- if re.search(r"-canary\.20\d{6}(?:\d{6})?$", tag):
+ from hermes_cli.update_channel import is_canary_tag
+
+ if is_canary_tag(tag):
return art, IconArt(source, colors=("#f5cc32", "#443808"))
return art, art
diff --git a/scripts/releases/darwin.py b/scripts/releases/darwin.py
index 2b129726942..a62902e6419 100644
--- a/scripts/releases/darwin.py
+++ b/scripts/releases/darwin.py
@@ -6,10 +6,10 @@ from typing import Any, Callable
from . import r2 as r2_module
from .semver import compare, is_valid_version
+from hermes_cli.update_channel import is_canary_tag
ARCHES = ("arm64", "x64")
_HASH_PATTERN = re.compile(r"^[A-Za-z0-9+/]{86}==$")
-_TAG_PATTERN = re.compile(r"^v\d+\.\d+\.\d+(?:-canary\.\d{14})?$")
def _darwin_feed(channel: str, light: bool = False) -> dict[str, Any]:
@@ -81,9 +81,9 @@ def merge_mac_feeds(legs: dict[str, str], tag: str, light: bool = False) -> dict
import hermes_yaml as yaml # lazy
version = tag[1:] if isinstance(tag, str) and tag.startswith("v") else ""
- if not is_valid_version(version) or not _TAG_PATTERN.match(tag):
+ if not is_valid_version(version):
raise ValueError("Invalid macOS release tag")
- selection = _darwin_feed("canary" if "-canary." in version else "stable", light)
+ selection = _darwin_feed("canary" if is_canary_tag(tag) else "stable", light)
expected = [f"{arch}-{selection['fileName']}" for arch in ARCHES]
if sorted(legs.keys()) != sorted(expected):
raise ValueError("Expected exactly one ARM64 and one x64 macOS feed")
diff --git a/scripts/releases/r2.py b/scripts/releases/r2.py
index 36233e5db0b..5ca27670e56 100644
--- a/scripts/releases/r2.py
+++ b/scripts/releases/r2.py
@@ -441,7 +441,9 @@ def _stream_and_hash(url: str, creds: dict[str, str], now: str, algorithm: str):
def channel_for_tag(tag: str) -> str:
"""'stable' for a stable tag, 'canary' for a -canary.<ts> tag."""
- return "canary" if re.search(r"-canary\.20\d{6}(?:\d{6})?$", tag) else "stable"
+ from hermes_cli.update_channel import is_canary_tag
+
+ return "canary" if is_canary_tag(tag) else "stable"
def staging_key_for(tag: str, filename: str) -> str:
@@ -810,10 +812,13 @@ def get_object(
def canary_doomed_keys(keys: list[str], cutoff: str) -> list[str]:
"""Keys whose own canary date (YYYYMMDD in the name) is before `cutoff`."""
+ from hermes_cli.update_channel import _CANARY_TAG_RE
+
+ tag_re = re.compile(_CANARY_TAG_RE.pattern.strip("^$"))
doomed = []
for key in keys:
- match = re.search(r"-canary\.(\d{8})", key)
- if match and match.group(1) < cutoff:
+ match = tag_re.search(key)
+ if match and match.group(0).split("-canary.", 1)[1][:8] < cutoff:
doomed.append(key)
return doomed