Skip to content

The agent that grows with you

feat(release): publish downloads pages to the release bucket

ethernetd233b6d7a9c5
diff --git a/apps/desktop/BUILDING.md b/apps/desktop/BUILDING.md
index 34a965f1c33..df126dac64b 100644
--- a/apps/desktop/BUILDING.md
+++ b/apps/desktop/BUILDING.md
@@ -127,6 +127,13 @@ files, and the Termux package. Linux release legs remain disabled and are listed
as not built. Only receipt-listed artifacts that exist in storage get download
links. Missing receipts show the failed or incomplete leg.
+Each commit build also writes a downloads page to
+`releases/commit/<FULL_SHA>/index.html` on the R2 public origin; a tag run
+writes its channel page instead (`releases/stable/index.html` or
+`releases/canary/index.html`). Pages list only objects the build actually
+staged, and a re-run of an older tag never replaces a newer channel page.
+`release.py --build-commit` prints the commit page URL before dispatching.
+
Commit builds require the signing credentials used by their release legs.
Store bundle envelopes remain unsigned for Partner Center, but these builds
never submit them. No GitHub release, updater feed, or APT channel is changed.
diff --git a/docs/stable-releases.md b/docs/stable-releases.md
index 406afa2f2b4..99cb0c7bc85 100644
--- a/docs/stable-releases.md
+++ b/docs/stable-releases.md
@@ -28,6 +28,12 @@ promotion can leave some services advanced and others unchanged. Such a run
stays red. Inspect its per-service results before retrying; do not rebuild or
replace the tested candidate to recover a pointer update.
+Promotion also replaces the stable downloads page at `releases/stable/index.html`
+on the R2 public origin, so the latest stable builds stay readable without
+GitHub. Canary tag builds own `releases/canary/index.html`, and commit builds
+own `releases/commit/<sha>/index.html`. Pages list only objects the build
+actually staged; a re-run of an older tag never regresses a channel page.
+
## Run a release
Use `scripts/release.py --bump patch --publish --remote <remote>` to create
diff --git a/scripts/release-content-types.json b/scripts/release-content-types.json
index 22ac92ff1c0..72633b401b9 100644
--- a/scripts/release-content-types.json
+++ b/scripts/release-content-types.json
@@ -1,5 +1,6 @@
{
".appinstaller": "application/appinstaller",
+ ".html": "text/html; charset=utf-8",
".msixbundle": "application/msixbundle",
".msix": "application/msix",
".deb": "application/vnd.debian.binary-package",
diff --git a/scripts/releases/commit_build.py b/scripts/releases/commit_build.py
index 14148b18d0d..36f25f25ee3 100644
--- a/scripts/releases/commit_build.py
+++ b/scripts/releases/commit_build.py
@@ -84,6 +84,7 @@ def dispatch_command(commit: str, repository: str, branch: str) -> list[str]:
def cmd_build_commit(args) -> None:
from scripts import release
+ from scripts.releases import r2
try:
remote = release.resolve_push_remote(args.remote)
@@ -95,7 +96,8 @@ def cmd_build_commit(args) -> None:
if not branch:
raise ValueError("could not resolve the repository default branch")
command = dispatch_command(commit, repository, branch)
- print(f"Commit: {commit}\nR2: releases/commit/{commit}/\nWorkflow: {repository}@{branch}")
+ page = r2.public_url_for(r2.public_base_url(), r2.commit_page_key_for(commit))
+ print(f"Commit: {commit}\nR2: {r2.commit_prefix_for(commit)}\nPage: {page}\nWorkflow: {repository}@{branch}")
print(shlex.join(command))
if not args.publish:
print("Dry run. Add --publish to dispatch. No tag, release or channel is changed.")
diff --git a/scripts/releases/r2.py b/scripts/releases/r2.py
index a6ea92a0be4..6f993af9e2a 100644
--- a/scripts/releases/r2.py
+++ b/scripts/releases/r2.py
@@ -430,13 +430,40 @@ def commit_prefix_for(commit: str) -> str:
return f"releases/commit/{commit}/"
+# Public download origin for object keys. CI supplies the authoritative
+# value as CLOUDFLARE_R2_PUBLIC_URL; the documented production origin is the
+# fallback so a local command can still name a page it is about to publish.
+DEFAULT_PUBLIC_URL = "https://hermes-assets.nousresearch.com"
+
+
+def public_base_url(explicit: str | None = None) -> str:
+ return (
+ explicit or os.environ.get("CLOUDFLARE_R2_PUBLIC_URL") or DEFAULT_PUBLIC_URL
+ ).rstrip("/")
+
+
+def public_url_for(base_url: str, key: str) -> str:
+ """Public download URL of an object key (segment-wise encoded)."""
+ return f"{base_url.rstrip('/')}/{quote(key, safe='/')}"
+
+
+def channel_page_key_for(channel: str) -> str:
+ """The mutable per-channel downloads page, replaced by each release."""
+ return f"releases/{channel}/index.html"
+
+
+def commit_page_key_for(commit: str) -> str:
+ """The per-commit-build downloads page (every expected binary, built or not)."""
+ return commit_prefix_for(commit) + "index.html"
+
+
def feed_dir_for(platform: str, channel: str) -> str:
return f"releases/{platform}/{channel}"
def cache_control_for(key: str) -> str | None:
"""APT indexes are mutable; by-hash indexes and versioned packages are not."""
- if key.endswith(".appinstaller") or key.startswith("releases/stable/") or (key.startswith("releases/darwin/") and key.endswith("-mac.yml")):
+ if key.endswith((".appinstaller", ".html")) or key.startswith("releases/stable/") or (key.startswith("releases/darwin/") and key.endswith("-mac.yml")):
return "no-store"
if not key.startswith("releases/termux/"):
return None
diff --git a/scripts/render-builds-table.py b/scripts/render-builds-table.py
index a4a3086a7ea..21f0898cc77 100644
--- a/scripts/render-builds-table.py
+++ b/scripts/render-builds-table.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
-"""Render the release download tables into <!-- HERMES_BUILDS_TABLE -->.
+"""Render the release download tables into <!-- HERMES_BUILDS_TABLE -->, and
+the same rows as standalone pages in the bucket.
Runs as the LAST job of desktop-bundled-release.yml, after every matrix
leg has uploaded, and edits the GitHub release body in place. The tables
@@ -10,6 +11,15 @@ GitHub release carries the notes only; the binaries live in the R2 bucket
under releases/tag/<tag>/, and the download links point at the R2 public
URL (CLOUDFLARE_R2_PUBLIC_URL / --r2-base-url).
+Every run also publishes the same rows as a tiny HTML page in the bucket,
+so a build can be read straight from the download origin:
+
+ releases/<channel>/index.html replaced by each release; the channel
+ page holds the latest stable or canary
+ builds for every variant
+ releases/commit/<sha>/index.html commit mode: every expected binary of
+ one commit build, built or not
+
Tables: Hermes Desktop (bundled) and Hermes Light, one row per (OS,
arch). Feed manifests (latest*/light*/canary*.yml), blockmaps and mac .zip
(an electron-updater delta target, not a user download) stay out of the
@@ -30,18 +40,19 @@ marker is kept as an HTML comment wrapper around the tables).
from __future__ import annotations
import argparse
+import html
import json
import os
import re
import subprocess
import sys
+import tempfile
from pathlib import Path
-from urllib.parse import quote
# Direct-script invocation starts with scripts/, not the repository root.
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
-from scripts.releases import handoff, r2 # noqa: E402
+from scripts.releases import handoff, r2, semver # noqa: E402
MARKER = "<!-- HERMES_BUILDS_TABLE -->"
END_MARKER = "<!-- /HERMES_BUILDS_TABLE -->"
@@ -85,10 +96,13 @@ def parse_assets(names: list[str]) -> dict[str, dict[tuple[str, str], tuple[str,
return out
-def render_tables(assets_by_app: dict, base_url: str) -> str:
- """The replacement block: marker + tables + end marker."""
- base = base_url.rstrip("/")
- sections = []
+def table_rows(assets_by_app: dict) -> list[tuple[str, list[tuple[str, str, str, str]]]]:
+ """[(section title, [(os label, arch label, kind label, object key), ...]), ...].
+
+ The ONE row set every sink renders (release-body markdown, R2 page);
+ a row exists only for an object that is actually in the bucket.
+ """
+ sections: list[tuple[str, list[tuple[str, str, str, str]]]] = []
for app, title in (("HermesBundled", "Hermes Desktop"), ("HermesLight", "Hermes Light (remote-only client)")):
rows = []
for key in _ROW_ORDER:
@@ -96,16 +110,23 @@ def render_tables(assets_by_app: dict, base_url: str) -> str:
if not entry:
continue
name, ext = entry
- os_name, arch = key
- rows.append(
- f"| {_OS_LABEL[os_name]} | {_ARCH_LABEL[key]} "
- f"| [{_KIND_LABEL[ext]}]({base}/{name}) |"
- )
+ rows.append((_OS_LABEL[key[0]], _ARCH_LABEL[key], _KIND_LABEL[ext], name))
if rows:
- sections.append(
- f"### {title}\n\n| OS | Architecture | Download |\n|---|---|---|\n"
- + "\n".join(rows)
- )
+ sections.append((title, rows))
+ return sections
+
+
+def render_tables(assets_by_app: dict, base_url: str) -> str:
+ """The replacement block: marker + tables + end marker."""
+ sections = []
+ for title, rows in table_rows(assets_by_app):
+ lines = [
+ f"| {os_name} | {arch} | [{kind}]({r2.public_url_for(base_url, name)}) |"
+ for os_name, arch, kind, name in rows
+ ]
+ sections.append(
+ f"### {title}\n\n| OS | Architecture | Download |\n|---|---|---|\n" + "\n".join(lines)
+ )
if not sections:
return ""
return MARKER + "\n## Downloads\n\n" + "\n\n".join(sections) + "\n" + END_MARKER
@@ -165,6 +186,10 @@ _COMMIT_EXPECTED = [
("Termux aarch64 (.deb)", "termux", r"^.*\.deb$"),
]
+# Linux release legs are disabled; they still get a row so a reader can see
+# they were never expected to publish.
+_COMMIT_DISABLED = ["Linux x64 (AppImage)", "Linux ARM64 (AppImage)"]
+
COMMIT_RECEIPT_NAMES = sorted({leg for _label, leg, _pattern in _COMMIT_EXPECTED})
_COMMIT_JOBS = {
"win32-x64": "build-win32", "win32-arm64": "build-win32",
@@ -197,41 +222,58 @@ def commit_expected_rows(names: list[str],
return rows
-def render_commit_summary(names: list[str], base_url: str, commit: str,
- receipts: dict[str, dict | None],
- failed_legs: list[str] | None = None) -> str:
- """Render every expected product without reading or changing a release."""
+def _validated_commit_inputs(commit: str, receipts: dict[str, dict | None]) -> None:
+ """The summary and the commit page must never disagree about what was
+ built, so both validate the SHA and every receipt the same way."""
r2.commit_prefix_for(commit)
for leg, receipt in receipts.items():
if receipt is not None:
handoff.validate_commit_receipt(receipt, commit, leg)
- base = base_url.rstrip("/")
+
+
+def commit_entries(commit: str, names: list[str], base_url: str,
+ receipts: dict[str, dict | None],
+ failed_legs: list[str] | None = None,
+ ) -> list[tuple[str, str, str | None, str | None]]:
+ """[(label, status, download URL or None, object basename or None)] — the
+ ONE row set the step summary and the commit page render. A link exists
+ only for a receipt-listed object that is really in the bucket."""
failed = set(failed_legs or [])
- lines = [
- f"## Commit build `{commit[:12]}`",
- "",
- "| Binary | Status | Download |",
- "|---|---|---|",
- ]
+ entries: list[tuple[str, str, str | None, str | None]] = []
for row in commit_expected_rows(names, receipts):
- label, key, state = row["label"], row["key"], row["state"]
+ label, leg, key, state = row["label"], row["leg"], row["key"], row["state"]
if state == "built":
- basename = key.rsplit("/", 1)[-1]
- link = f"{base}/{quote(key, safe='/')}"
- lines.append(f"| {label} | ✅ Built | [{basename}]({link}) |")
+ entries.append((label, "✅ Built", r2.public_url_for(base_url, key), key.rsplit("/", 1)[-1]))
elif state == "receipt-missing":
- related = failed.intersection({row["leg"], _COMMIT_JOBS[row["leg"]]})
+ related = failed.intersection({leg, _COMMIT_JOBS[leg]})
blame = f"failed: {', '.join(sorted(related))}" if related \
else "leg incomplete or upload interrupted"
- lines.append(f"| {label} | ❌ Not built ({blame}) | — |")
+ entries.append((label, f"❌ Not built ({blame})", None, None))
elif state == "object-missing":
- lines.append(f"| {label} | ❌ Not built (receipt present but object missing) | — |")
+ entries.append((label, "❌ Not built (receipt present but object missing)", None, None))
elif state == "receipt-omits":
- lines.append(f"| {label} | ❌ Not built (artifact absent from receipt) | — |")
+ entries.append((label, "❌ Not built (artifact absent from receipt)", None, None))
else:
- lines.append(f"| {label} | ❌ Not built (ambiguous: multiple objects match) | — |")
- for label in ("Linux x64 (AppImage)", "Linux ARM64 (AppImage)"):
- lines.append(f"| {label} | ❌ Not built (release leg disabled) | — |")
+ entries.append((label, "❌ Not built (ambiguous: multiple objects match)", None, None))
+ for label in _COMMIT_DISABLED:
+ entries.append((label, "❌ Not built (release leg disabled)", None, None))
+ return entries
+
+
+def render_commit_summary(names: list[str], base_url: str, commit: str,
+ receipts: dict[str, dict | None],
+ failed_legs: list[str] | None = None) -> str:
+ """Render every expected product without reading or changing a release."""
+ _validated_commit_inputs(commit, receipts)
+ lines = [
+ f"## Commit build `{commit[:12]}`",
+ "",
+ "| Binary | Status | Download |",
+ "|---|---|---|",
+ ]
+ for label, status, url, basename in commit_entries(commit, names, base_url, receipts, failed_legs):
+ cell = f"[{basename}]({url})" if url and basename else "—"
+ lines.append(f"| {label} | {status} | {cell} |")
return "\n".join([*lines, ""])
@@ -261,6 +303,143 @@ def failed_legs_from_release_needs(release_needs_json: str | None) -> list[str]:
if isinstance(info, dict) and info.get("result") not in ("success", "skipped"))
+# ---------------------------------------------------------------------------
+# Bucket pages: the same rows as the tables, served from the download origin
+# ---------------------------------------------------------------------------
+
+_PAGE_STYLE = (
+ "body{font:15px/1.5 system-ui,-apple-system,'Segoe UI',sans-serif;margin:2rem auto;"
+ "max-width:54rem;padding:0 1rem;color:#1a1a1a;background:#fff}"
+ "h1{font-size:1.4rem}h2{font-size:1.05rem;margin-top:1.75rem}"
+ "p{color:#444}table{border-collapse:collapse;width:100%}"
+ "th,td{text-align:left;padding:.45rem .6rem;border-bottom:1px solid #dcdcdc}"
+ "th{font-weight:600}a{color:#0a58ca}code{font-size:.95em}"
+)
+
+# The record a channel page keeps of the release it describes; the write
+# guard reads it back so an older tag re-run never regresses the page.
+_BUILD_META_RE = re.compile(r'<meta name="hermes-build" content="([^"]*)"')
+
+
+def _page(title: str, build: str, body: list[str]) -> str:
+ return (
+ '<!DOCTYPE html>\n<html lang="en">\n<head>\n<meta charset="utf-8">\n'
+ '<meta name="viewport" content="width=device-width, initial-scale=1">\n'
+ f'<meta name="hermes-build" content="{html.escape(build, quote=True)}">\n'
+ f"<title>{html.escape(title)}</title>\n<style>{_PAGE_STYLE}</style>\n</head>\n<body>\n"
+ + "\n".join(body)
+ + "\n</body>\n</html>\n"
+ )
+
+
+def _table(headers: tuple[str, ...], rows: list[list[str]]) -> list[str]:
+ head = "".join(f"<th>{html.escape(name)}</th>" for name in headers)
+ body = ["<tr>" + "".join(f"<td>{cell}</td>" for cell in row) + "</tr>" for row in rows]
+ return [f"<table>\n<thead><tr>{head}</tr></thead>\n<tbody>", *body, "</tbody>\n</table>"]
+
+
+def _link(url: str) -> str:
+ return f'<a href="{html.escape(url, quote=True)}">'
+
+
+def render_page(tag: str, assets_by_app: dict, base_url: str) -> str:
+ """The channel page: the release-body download table as HTML."""
+ channel = r2.channel_for_tag(tag)
+ body = [
+ f"<h1>Hermes Desktop {channel} builds</h1>",
+ f"<p>Release <code>{html.escape(tag)}</code>. Only objects this release "
+ "actually staged in the bucket are listed.</p>",
+ ]
+ for title, rows in table_rows(assets_by_app):
+ body.append(f"<h2>{html.escape(title)}</h2>")
+ body.extend(_table(
+ ("OS", "Architecture", "Download"),
+ [[html.escape(os_name), html.escape(arch),
+ f"{_link(r2.public_url_for(base_url, name))}{html.escape(kind)}</a>"]
+ for os_name, arch, kind, name in rows],
+ ))
+ return _page(f"Hermes Desktop {channel} builds", tag, body)
+
+
+def render_commit_page(commit: str, names: list[str], base_url: str,
+ receipts: dict[str, dict | None],
+ failed_legs: list[str] | None = None) -> str:
+ """The commit-build page: every expected binary, built or not."""
+ _validated_commit_inputs(commit, receipts)
+ rows = []
+ for label, status, url, basename in commit_entries(commit, names, base_url, receipts, failed_legs):
+ cell = (f"{_link(url)}{html.escape(basename)}</a>" if url and basename else "—")
+ rows.append([html.escape(label), html.escape(status), cell])
+ body = [
+ f"<h1>Hermes commit build <code>{html.escape(commit[:12])}</code></h1>",
+ f"<p>Commit <code>{html.escape(commit)}</code>. Every expected binary is listed; "
+ "a row without a link was not built.</p>",
+ *_table(("Binary", "Status", "Download"), rows),
+ ]
+ return _page(f"Hermes commit build {commit[:12]}", commit, body)
+
+
+def recorded_build(page: str | None) -> str | None:
+ """The release tag or commit a page in the bucket describes."""
+ match = _BUILD_META_RE.search(page or "")
+ return (match.group(1) or None) if match else None
+
+
+def supersedes(existing_page: str | None, tag: str) -> bool:
+ """Whether `tag` may replace the channel page.
+
+ Channel pages are mutable pointers: a re-run of an OLDER tag must not
+ regress the page a newer release already published (the release body
+ cannot regress — each tag owns its own release). Ordering uses the same
+ semver authority the feeds do; an absent or unreadable record is written,
+ because the new page is then the best available information.
+ """
+ recorded = recorded_build(existing_page)
+ if not recorded:
+ return True
+ try:
+ return semver.compare(recorded.lstrip("v"), tag.lstrip("v")) <= 0
+ except ValueError:
+ return True
+
+
+def write_page(key: str, page: str, base_url: str) -> str:
+ """PUT one page object at `key` (a FULL key, no tag archive) and return
+ its public URL. Mutable: the page is replaced by each build of its own
+ channel/commit."""
+ with tempfile.NamedTemporaryFile("w", encoding="utf-8", newline="\n",
+ suffix=".html", delete=False) as handle:
+ handle.write(page)
+ path = handle.name
+ try:
+ r2.put(tag="", key=key, file=path, key_is_full=True)
+ finally:
+ os.unlink(path)
+ url = r2.public_url_for(base_url, key)
+ print(f"✓ Page {url} ({len(page)} bytes)")
+ return url
+
+
+def existing_page(key: str) -> str | None:
+ """The page currently at `key`, or None when nothing is published there."""
+ try:
+ creds, base, bucket = r2.credentials()
+ return r2.get_object(creds, base, bucket, key, r2.amz_timestamp())
+ except r2.R2RequestError as err:
+ if err.status == 404:
+ return None
+ raise
+
+
+def write_channel_page(tag: str, assets_by_app: dict, base_url: str) -> str | None:
+ """Publish releases/<channel>/index.html for the tag's own channel."""
+ key = r2.channel_page_key_for(r2.channel_for_tag(tag))
+ if not supersedes(existing_page(key), tag):
+ print(f"::warning::{key} already describes a newer release; leaving it unchanged")
+ return None
+ return write_page(key, render_page(tag, assets_by_app, base_url), base_url)
+
+
def r2_object_names_under(prefix: str) -> list[str]:
return r2.list_objects(prefix=prefix)["keys"]
@@ -299,7 +478,8 @@ def main() -> int:
parser.add_argument("--r2-base-url", default=os.environ.get("CLOUDFLARE_R2_PUBLIC_URL"),
help="Public base URL of the R2 bucket (default: $CLOUDFLARE_R2_PUBLIC_URL)")
parser.add_argument("--dry-run", action="store_true",
- help="Print the spliced body instead of editing the release")
+ help="Print the spliced body instead of editing the release "
+ "(writes nothing, including the channel page)")
parser.add_argument("--pending-run-url", default=None,
help="Render a 'builds in progress' link to this workflow run "
"instead of the tables")
@@ -329,6 +509,9 @@ def main() -> int:
block = render_commit_summary(names, args.r2_base_url, commit, receipts, failed_legs)
with open(args.summary_out, "a", encoding="utf-8") as out:
out.write(block)
+ write_page(r2.commit_page_key_for(commit),
+ render_commit_page(commit, names, args.r2_base_url, receipts, failed_legs),
+ args.r2_base_url)
built = sum(1 for row in commit_expected_rows(names, receipts) if row["state"] == "built")
print(f"✓ Commit summary appended to {args.summary_out} ({built}/{len(_COMMIT_EXPECTED)} binaries built)")
return 0
@@ -355,10 +538,15 @@ def main() -> int:
print("::error::--r2-base-url (or CLOUDFLARE_R2_PUBLIC_URL) is required to render the tables")
return 1
names = r2_object_names(args.tag)
- block = render_tables(parse_assets(names), args.r2_base_url)
+ assets = parse_assets(names)
+ block = render_tables(assets, args.r2_base_url)
if not block:
print("::warning::no table-shaped assets for this tag in the bucket; leaving the body unchanged")
return 0
+ # The channel page is independent of the release body (and of the
+ # marker), so it is published even if the body cannot be edited.
+ if not args.dry_run:
+ write_channel_page(args.tag, assets, args.r2_base_url)
if MARKER not in body:
print("::warning::release body has no HERMES_BUILDS_TABLE marker; leaving it unchanged")
return 0
diff --git a/tests/scripts/test_release_build_commit.py b/tests/scripts/test_release_build_commit.py
index 57d79d93855..c756ecab67e 100644
--- a/tests/scripts/test_release_build_commit.py
+++ b/tests/scripts/test_release_build_commit.py
@@ -29,6 +29,7 @@ def fixture_repo(tmp_path):
git(repo, 'push', '-q', 'origin', 'main')
git(repo, 'remote', 'set-url', 'origin', 'https://github.com/fixture-owner/fixture-repo.git')
for relative in ('scripts/release.py', 'scripts/releases/commit_build.py',
+ 'scripts/releases/r2.py', 'scripts/release-content-types.json',
'hermes_cli/__init__.py', 'hermes_cli/update_channel.py',
'hermes_cli/runtime_paths.py', 'hermes_constants.py'):
dest = repo / relative
@@ -96,6 +97,9 @@ def test_commit_build_cli_dispatches_only_the_resolved_remote_commit(tmp_path):
result, calls = invoke('--build-commit', revision)
assert result.returncode == 0, result.stderr
assert f'Commit: {tip}' in result.stdout and f'releases/commit/{tip}/' in result.stdout
+ # The commit build's downloads page is named before anything is
+ # dispatched, so the URL can be opened once the matrix finishes.
+ assert 'Page: http' in result.stdout and f'releases/commit/{tip}/index.html' in result.stdout
assert not any(call[1:3] == ['workflow', 'run'] for call in calls)
result, calls = invoke('--build-commit', tip, '--publish')
assert result.returncode == 0, result.stderr
diff --git a/tests/scripts/test_release_r2.py b/tests/scripts/test_release_r2.py
index 9f9b0c1163b..1aab2f03a0e 100644
--- a/tests/scripts/test_release_r2.py
+++ b/tests/scripts/test_release_r2.py
@@ -34,11 +34,16 @@ from scripts.releases.r2 import (
canonical_query,
canonical_request,
channel_for_tag,
+ channel_page_key_for,
+ commit_page_key_for,
+ commit_prefix_for,
content_type_for,
encode_key_path,
feed_dir_for,
feed_referenced_keys,
parse_list_xml,
+ public_base_url,
+ public_url_for,
publish_feed_uploads,
referenced_feed_bundle_filenames,
rfc3986_encode,
@@ -198,14 +203,41 @@ def test_staging_key_and_feed_dir_layout_keys():
assert feed_dir_for("darwin", "canary") == "releases/darwin/canary"
+def test_download_page_keys_and_public_urls():
+ assert channel_page_key_for("stable") == "releases/stable/index.html"
+ assert channel_page_key_for("canary") == "releases/canary/index.html"
+ commit = "a" * 40
+ assert commit_page_key_for(commit) == f"releases/commit/{commit}/index.html"
+ assert commit_prefix_for(commit) == f"releases/commit/{commit}/"
+ assert public_url_for("https://cdn.example.com/", "releases/tag/v1/Hermes-1-x64.msix") == (
+ "https://cdn.example.com/releases/tag/v1/Hermes-1-x64.msix"
+ )
+ # Segment-wise encoding: spaces and non-ASCII survive a link.
+ assert public_url_for("https://cdn.example.com", "a b/\u00fc.msix") == (
+ "https://cdn.example.com/a%20b/%C3%BC.msix"
+ )
+
+
+def test_public_base_url_precedence(monkeypatch):
+ # Explicit value, then $CLOUDFLARE_R2_PUBLIC_URL, then the documented
+ # production origin — so a local command always names a real page.
+ monkeypatch.delenv("CLOUDFLARE_R2_PUBLIC_URL", raising=False)
+ assert public_base_url() == "https://hermes-assets.nousresearch.com"
+ monkeypatch.setenv("CLOUDFLARE_R2_PUBLIC_URL", "https://cdn.example.com")
+ assert public_base_url() == "https://cdn.example.com"
+ assert public_base_url("https://explicit.example.com/") == "https://explicit.example.com"
+
+
def test_content_type_for_maps_msix_and_appinstaller():
assert content_type_for("HermesBundled-0.28.0-win-x64.msix") == "application/msix"
assert content_type_for("HermesBundled-0.28.0-win.msixbundle") == "application/msixbundle"
assert content_type_for("stable.appinstaller") == "application/appinstaller"
+ assert content_type_for("releases/stable/index.html") == "text/html; charset=utf-8"
assert content_type_for("HermesBundled-0.28.0-mac-x64.dmg") is None
assert content_type_for("latest-mac.yml") is None
# Case-insensitive on the suffix.
assert content_type_for("X.APPINSTALLER") == "application/appinstaller"
+ assert content_type_for("INDEX.HTML") == "text/html; charset=utf-8"
def test_apt_mutable_metadata_revalidates_immutable_bytes_cache():
@@ -224,6 +256,10 @@ def test_apt_mutable_metadata_revalidates_immutable_bytes_cache():
"public, max-age=31536000, immutable"
)
assert cache_control_for("releases/win32/stable/stable.appinstaller") == "no-store"
+ # Downloads pages are mutable pointers, like feed manifests.
+ assert cache_control_for("releases/stable/index.html") == "no-store"
+ assert cache_control_for("releases/canary/index.html") == "no-store"
+ assert cache_control_for(f"releases/commit/{'a' * 40}/index.html") == "no-store"
def test_canonical_request_reads_mixed_case_header_values():
@@ -551,6 +587,28 @@ def test_put_streams_a_file_and_verifies_size(r2_server):
assert puts[0][2]["x-amz-content-sha256"] == expected_hash
+def test_put_page_object_carries_html_type_and_no_store(r2_server):
+ """A downloads page must RENDER in a browser: the object it is stored
+ under has to arrive as HTML, and it is a mutable pointer, so it must not
+ be cached. Without the registered content type R2 serves it as an opaque
+ octet-stream download."""
+ import tempfile
+
+ page = "<!DOCTYPE html>\n<html lang=\"en\"><body><h1>Hermes stable builds</h1></body></html>\n"
+ with tempfile.NamedTemporaryFile("w", encoding="utf-8", newline="\n", delete=False) as handle:
+ handle.write(page)
+ path = handle.name
+ try:
+ r2.put(tag="", key=r2.channel_page_key_for("stable"), file=path, key_is_full=True)
+ finally:
+ os.unlink(path)
+ stored, _etag = r2_server.store["releases/stable/index.html"]
+ assert stored == page.encode("utf-8")
+ headers = [r[2] for r in r2_server.requests if r[0] == "PUT"][0]
+ assert headers["Content-Type"] == "text/html; charset=utf-8"
+ assert headers["Cache-Control"] == "no-store"
+
+
def test_put_immutable_conflict_verifies_remote_bytes(r2_server):
import tempfile
diff --git a/tests/scripts/test_render_builds_table.py b/tests/scripts/test_render_builds_table.py
index 2090f9b4bad..52da6e1154b 100644
--- a/tests/scripts/test_render_builds_table.py
+++ b/tests/scripts/test_render_builds_table.py
@@ -12,6 +12,10 @@ and stays out of the tables), not the NSIS .exe.
"""
import importlib.util
+import json
+import re
+import subprocess
+import sys
from pathlib import Path
_SCRIPT = Path(__file__).resolve().parents[2] / "scripts" / "render-builds-table.py"
@@ -141,3 +145,120 @@ class TestPendingPlaceholder:
assert "https://x/runs/1" not in twice
assert twice.count("https://x/runs/2") == 1
assert twice.count(rbt.END_MARKER) == 1
+
+
+class TestBucketPage:
+ """The page is the same row set as the release-body table.
+
+ Every download link in the markdown table exists in the page, and the
+ artifacts the table deliberately hides (zip/msixbundle/blockmap) stay
+ out of the page too — a page that outlives the release body must not
+ advertise a delta target as a download.
+ """
+
+ def test_page_carries_exactly_the_table_rows(self):
+ block = rbt.render_tables(rbt.parse_assets(ASSETS), BASE_URL)
+ page = rbt.render_page("v0.28.0", rbt.parse_assets(ASSETS), BASE_URL)
+ links = re.findall(r"\]\((https?://[^)]+)\)", block)
+ assert links # the table is non-empty, so the comparison means something
+ for url in links:
+ assert f'href="{url}"' in page
+ # One row per table row, plus one header row per section.
+ assert page.count("<tr>") == len(links) + page.count("<table>")
+ assert ".zip" not in page and ".blockmap" not in page and ".msixbundle" not in page
+ # A leg that never uploaded has no row in either sink, while a leg
+ # that did (linux-x64) is listed.
+ assert BASE_URL + "/releases/tag/v0.28.0/HermesBundled-0.28.0-linux-x64.AppImage" in page
+ assert "linux-arm64" not in page
+
+ def test_page_names_the_build_it_describes(self):
+ page = rbt.render_page("v0.28.0", rbt.parse_assets(ASSETS), BASE_URL)
+ assert rbt.recorded_build(page) == "v0.28.0"
+ canary = rbt.render_page("v0.28.0-canary.20260818101010", rbt.parse_assets(ASSETS), BASE_URL)
+ assert rbt.recorded_build(canary) == "v0.28.0-canary.20260818101010"
+ assert "canary" in canary
+
+ def test_older_tag_never_regresses_the_channel_page(self):
+ """A re-run of an old tag must not overwrite the page a newer release
+ published; the recorded tag is compared with the feed's own authority."""
+ current = rbt.render_page("v0.29.0", rbt.parse_assets(ASSETS), BASE_URL)
+ assert not rbt.supersedes(current, "v0.28.0")
+ assert not rbt.supersedes(current, "v0.28.0-canary.20260818101010")
+ assert rbt.supersedes(current, "v0.29.0") # same tag re-run rewrites
+ assert rbt.supersedes(current, "v0.30.0")
+ newer_canary = rbt.render_page("v0.29.0-canary.20260901090000", rbt.parse_assets(ASSETS), BASE_URL)
+ assert not rbt.supersedes(newer_canary, "v0.29.0-canary.20260801090000")
+ assert rbt.supersedes(newer_canary, "v0.29.0-canary.20260901090001")
+ # Nothing published yet, or an unreadable record: the new page wins.
+ assert rbt.supersedes(None, "v0.28.0")
+ assert rbt.supersedes("<html>garbage</html>", "v0.28.0")
+
+ def test_channel_page_key_follows_the_tag(self):
+ assert rbt.r2.channel_page_key_for(rbt.r2.channel_for_tag("v0.28.0")) == "releases/stable/index.html"
+ assert rbt.r2.channel_page_key_for(
+ rbt.r2.channel_for_tag("v0.28.0-canary.20260818101010")) == "releases/canary/index.html"
+
+
+class TestTagRunPublishesThePage:
+ """The real CLI path: the page is uploaded for the tag's own channel."""
+
+ TAG = "v0.28.0-canary.20260818101010"
+ KEYS = [
+ f"releases/tag/{TAG}/HermesBundled-0.28.0-canary.20260818101010-win-x64.msix",
+ f"releases/tag/{TAG}/HermesBundled-0.28.0-canary.20260818101010-mac-arm64.dmg",
+ f"releases/tag/{TAG}/HermesBundled-0.28.0-canary.20260818101010-win.msixbundle",
+ f"releases/tag/{TAG}/HermesLight-0.28.0-canary.20260818101010-win-x64.msix",
+ "releases/tag/v0.27.0/HermesBundled-0.27.0-win-x64.msix", # neighbor release
+ ]
+
+ @staticmethod
+ def _gh(argv, **kwargs):
+ if argv[:3] == ["gh", "release", "view"]:
+ body = f"# Notes\n\n{rbt.MARKER}\n\n## Changes\n- x\n"
+ return subprocess.CompletedProcess(argv, 0, stdout=json.dumps({"body": body}), stderr="")
+ if argv[:3] == ["gh", "release", "edit"]:
+ return subprocess.CompletedProcess(argv, 0, stdout="", stderr="")
+ raise AssertionError(argv)
+
+ def test_page_upload_key_and_bytes(self, monkeypatch, capsys, tmp_path):
+ uploads: list[tuple[str, str, bool]] = []
+ monkeypatch.setattr(rbt.r2, "list_objects", lambda prefix="": {"keys": self.KEYS})
+ monkeypatch.setattr(rbt, "existing_page", lambda key: None)
+ monkeypatch.setattr(rbt.r2, "put", lambda tag, key, file, key_is_full=False, immutable=False:
+ uploads.append((key, Path(file).read_text(encoding="utf-8"), key_is_full)))
+ monkeypatch.setattr(rbt.subprocess, "run", self._gh)
+ monkeypatch.setattr(sys, "argv", [
+ "render-builds-table.py", "--tag", self.TAG, "--repo", "o/r", "--r2-base-url", BASE_URL,
+ ])
+ assert rbt.main() == 0
+ assert len(uploads) == 1
+ key, page, key_is_full = uploads[0]
+ # Canary tag → the canary channel page, as a full key (not a tag name).
+ assert key == "releases/canary/index.html" and key_is_full
+ assert rbt.recorded_build(page) == self.TAG
+ for name in ("HermesBundled-0.28.0-canary.20260818101010-win-x64.msix",
+ "HermesBundled-0.28.0-canary.20260818101010-mac-arm64.dmg",
+ "HermesLight-0.28.0-canary.20260818101010-win-x64.msix"):
+ assert f"{BASE_URL}/releases/tag/{self.TAG}/{name}" in page
+ # The neighbor release and the hidden artifact shapes stay out.
+ assert "v0.27.0" not in page and ".msixbundle" not in page
+ assert f"✓ Page {BASE_URL}/releases/canary/index.html" in capsys.readouterr().out
+
+ def test_dry_run_and_stale_tags_write_nothing(self, monkeypatch, tmp_path):
+ uploads: list[str] = []
+ monkeypatch.setattr(rbt.r2, "list_objects", lambda prefix="": {"keys": self.KEYS})
+ monkeypatch.setattr(rbt.r2, "put", lambda **kwargs: uploads.append(kwargs["key"]))
+ monkeypatch.setattr(rbt.subprocess, "run", self._gh)
+ stale = rbt.render_page("v0.29.0", rbt.parse_assets(ASSETS), BASE_URL)
+ monkeypatch.setattr(rbt, "existing_page", lambda key: stale)
+ monkeypatch.setattr(sys, "argv", [
+ "render-builds-table.py", "--tag", self.TAG, "--repo", "o/r", "--r2-base-url", BASE_URL,
+ ])
+ assert rbt.main() == 0 # stale tag: page untouched
+ monkeypatch.setattr(rbt, "existing_page", lambda key: None)
+ monkeypatch.setattr(sys, "argv", [
+ "render-builds-table.py", "--tag", self.TAG, "--repo", "o/r",
+ "--r2-base-url", BASE_URL, "--dry-run",
+ ])
+ assert rbt.main() == 0 # dry run: nothing published
+ assert uploads == []
diff --git a/tests/scripts/test_render_builds_table_commit.py b/tests/scripts/test_render_builds_table_commit.py
index f4acd43b438..1ba358ee015 100644
--- a/tests/scripts/test_render_builds_table_commit.py
+++ b/tests/scripts/test_render_builds_table_commit.py
@@ -10,6 +10,8 @@ from __future__ import annotations
import importlib.util
import json
+import re
+import sys
from pathlib import Path
import pytest
@@ -221,3 +223,52 @@ def test_summary_uses_exact_nested_keys_and_lists_both_universal_bundles():
assert len(built) == len(names)
assert any("Store" in line and "MSIXBUNDLE" in line for line in built)
assert "Linux x64" in summary and "Linux ARM64" in summary
+
+
+def test_commit_page_matches_the_summary_rows():
+ """Two sinks, ONE row set: every link and every status in the step
+ summary appears on the page, and neither sink drops a missing binary."""
+ receipts = _receipts_all_built()
+ names = _all_built_names()
+ summary = rbt.render_commit_summary(names, BASE, COMMIT, receipts)
+ page = rbt.render_commit_page(COMMIT, names, BASE, receipts)
+ links = re.findall(r"\]\((https?://[^)]+)\)", summary)
+ assert len(links) == len(rbt._COMMIT_EXPECTED)
+ for url in links:
+ assert f'href="{url}"' in page
+ assert page.count("✅ Built") == summary.count("✅ Built") == len(rbt._COMMIT_EXPECTED)
+ assert page.count("❌ Not built") == summary.count("❌ Not built") == len(rbt._COMMIT_DISABLED)
+ assert rbt.recorded_build(page) == COMMIT
+
+
+def test_commit_page_lists_a_missing_binary_without_a_link():
+ receipts = _receipts_all_built()
+ receipts["darwin-arm64"] = None
+ names = _names("HermesBundled-0.28.0-win-x64.msix")
+ page = rbt.render_commit_page(COMMIT, names, BASE, receipts, failed_legs=["build-darwin"])
+ assert page.count("<tr>") == len(rbt._COMMIT_EXPECTED) + len(rbt._COMMIT_DISABLED) + 1
+ assert "failed: build-darwin" in page
+ # Only the one staged object was built, so it is the only anchor.
+ assert page.count("<a href=") == 1
+
+
+def test_commit_run_publishes_the_commit_page(tmp_path, monkeypatch, capsys):
+ """The real CLI path: commit mode writes the summary AND the page."""
+ summary = tmp_path / "summary.md"
+ uploads: list[tuple[str, str, bool]] = []
+ receipts = _receipts_all_built()
+ monkeypatch.setattr(rbt.r2, "list_objects", lambda prefix="": {"keys": _all_built_names()})
+ monkeypatch.setattr(rbt.handoff, "read_commit_receipt", lambda commit, name: receipts[name])
+ monkeypatch.setattr(rbt.r2, "put", lambda tag, key, file, key_is_full=False, immutable=False:
+ uploads.append((key, Path(file).read_text(encoding="utf-8"), key_is_full)))
+ monkeypatch.setattr(sys, "argv", ["render-builds-table.py", "--summary-commit", COMMIT,
+ "--summary-out", str(summary), "--r2-base-url", BASE])
+ assert rbt.main() == 0
+ assert len(uploads) == 1
+ key, page, key_is_full = uploads[0]
+ assert key == f"releases/commit/{COMMIT}/index.html" and key_is_full
+ assert f"✓ Page {BASE}/releases/commit/{COMMIT}/index.html" in capsys.readouterr().out
+ written = summary.read_text(encoding="utf-8")
+ for url in re.findall(r"\]\((https?://[^)]+)\)", written):
+ assert f'href="{url}"' in page
+ assert written.count("✅ Built") == page.count("✅ Built") == len(rbt._COMMIT_EXPECTED)