Skip to content

The agent that grows with you

fix(release): bind stable package versions and manifest origins

ethernet8c2e88aa4d5a
diff --git a/apps/desktop/scripts/msix-shared.test.mjs b/apps/desktop/scripts/msix-shared.test.mjs
index f96175d42cf..4f34bf4832a 100644
--- a/apps/desktop/scripts/msix-shared.test.mjs
+++ b/apps/desktop/scripts/msix-shared.test.mjs
@@ -6,7 +6,6 @@ import assert from 'node:assert/strict'
import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
-import { fileURLToPath } from 'node:url'
import { beforeEach, test, vi } from 'vitest'
vi.mock('node:child_process', () => ({
@@ -41,11 +40,17 @@ beforeEach(() => {
execFileSync.mockReset()
})
-test('stable tag keeps the 3-part version plus .0', () => {
- const desktop = makeFakeDesktop('0.27.1')
- const { version, fileVersion } = msix.appIdentity(desktop, 'v0.27.1')
- assert.equal(version, '0.27.1.0')
- assert.equal(fileVersion, '0.27.1')
+test('explicit stable tag owns the package version, independent of checkout metadata', () => {
+ const desktop = makeFakeDesktop('0.1.0')
+ try {
+ const { version, fileVersion } = msix.appIdentity(desktop, 'v0.27.1')
+ assert.equal(version, '0.27.1.0')
+ assert.equal(fileVersion, '0.27.1')
+ assert.equal(msix.appIdentity(desktop, '').version, '0.1.0.0')
+ assert.throws(() => msix.appIdentity(desktop, 'v0.27.1-invalid'), /release tag/)
+ } finally {
+ fs.rmSync(desktop, { recursive: true, force: true })
+ }
})
test('canary version is tag base + minutes since the same-minor stable', () => {
diff --git a/docs/stable-releases.md b/docs/stable-releases.md
index e9117537135..7d7c81724a6 100644
--- a/docs/stable-releases.md
+++ b/docs/stable-releases.md
@@ -36,9 +36,19 @@ its version commit, stable tag and draft. Stable dispatch selects
a moved tag, a tag outside repository main, or a project-version mismatch.
Canary dispatch still uses the default branch for its workflow/cache scope.
-To resume an existing draft, dispatch `Stable Release` with the exact tag as
-both the workflow ref and the `tag` input. Keep tags immutable. The local
-workflow calls and their checkouts use the tag's commit, not moving main.
+To start the gate for an existing draft, dispatch `Stable Release` with the
+exact tag as both the workflow ref and the `tag` input. Keep tags immutable.
+The local workflow calls and their checkouts use the tag's commit, not moving
+main.
+
+For a failed publication or promotion, retry the failed jobs in the original
+run while its candidate artifacts remain available. Cross-phase artifact
+handoff is scoped to that run. Immutable uploads accept an existing object
+only after verifying that its bytes match; different bytes fail. Do not delete
+archive objects or rebuild signed candidates under the same tag to bypass a
+conflict. A fresh dispatch starts the build phases again and is not a
+promotion-only retry. If the original artifacts are unavailable, stop recovery
+rather than replace the accepted candidate.
## Signed-package baseline
@@ -49,9 +59,12 @@ provenance. The next run combines those records with its candidate manifest
and uses the existing native bundled-update drivers.
For an existing stable release that predates this metadata, supply
-`baseline-manifest` as an HTTPS URL to an equivalent manifest of its actual
-published packages. The baseline tag must be a published stable release,
-package identities must agree, and versions must increase. Missing baseline
+`baseline-manifest` as an HTTPS URL on the configured R2 public origin to an
+equivalent manifest of its actual published packages. Manifest redirects must
+stay on the same origin. The baseline tag must be a published stable release,
+package identities must agree, and versions must increase. Stable sideload
+Windows versions must equal the tag's three components plus `.0`; Store
+packages retain their separate version policy. Missing baseline
artifacts are a blocker, not permission to fabricate or skip acceptance.
See [the bundled update contract](../tests/install/BUNDLED_UPDATES.md).
diff --git a/scripts/bundles/release_artifacts.py b/scripts/bundles/release_artifacts.py
index be40a832d29..82f71c0ed32 100644
--- a/scripts/bundles/release_artifacts.py
+++ b/scripts/bundles/release_artifacts.py
@@ -179,8 +179,6 @@ def materialize(manifest: dict, root: Path, *, public_base: str, store_only: boo
file.write(chunk)
if digest.hexdigest() != item["sha256"]:
raise ValueError(f"Artifact digest mismatch: {relative}")
- if not manifest.get("files"):
- raise ValueError("Missing candidate file receipts")
def publish(manifest: dict, root: Path, public_base: str) -> None:
diff --git a/scripts/msix-shared.mjs b/scripts/msix-shared.mjs
index 7c4260c950d..c19b6b932e4 100644
--- a/scripts/msix-shared.mjs
+++ b/scripts/msix-shared.mjs
@@ -326,10 +326,13 @@ export function appIdentity(desktopDir, tag = process.env.HERMES_PAYLOAD_TAG ||
name: identity.appNamePascal,
}
}
+ if (tag && !STABLE_TAG_RE.test(tag)) throw new Error(`Invalid release tag: ${tag}`)
+ // Release builds override Electron's version without rewriting package.json.
+ const version = tag ? tag.slice(1) : pkg.version
return {
identity,
- version: `${pkg.version}.0`,
- fileVersion: pkg.version,
+ version: `${version}.0`,
+ fileVersion: version,
name: identity.appNamePascal,
}
}
diff --git a/scripts/releases/stable.py b/scripts/releases/stable.py
index b7da648ea3c..43f39b13933 100644
--- a/scripts/releases/stable.py
+++ b/scripts/releases/stable.py
@@ -56,6 +56,8 @@ def validate_candidates(manifest: dict, tag: str, commit: str, public_base: str)
raise ValueError(f"Invalid candidate digest or identity: {target}")
if item["platform"] == "windows":
windows_version(item.get("version", ""))
+ if item["version"] != f"{tag[1:]}.0":
+ raise ValueError("Stable Windows package version must match its release tag")
if not item.get("publisher") or not item.get("applicationId") or not url.path.endswith(".msixbundle"):
raise ValueError("Windows candidate needs publisher, applicationId and MSIX bundle")
elif item["platform"] == "macos":
@@ -100,13 +102,20 @@ def plan_transitions(previous: dict, candidate: dict, public_base: str) -> list[
return result
-def read_manifest(url: str, expected_hash: str | None = None, *, opener=urllib.request.urlopen) -> dict:
+def read_manifest(url: str, expected_hash: str | None = None, *, expected_origin: str | None = None,
+ opener=urllib.request.urlopen) -> dict:
location = urlsplit(url)
- if location.scheme != "https" or location.username or location.password:
- raise ValueError("Manifest URL must use HTTPS without credentials")
+ origin = urlsplit(expected_origin or url)
+
+ def check_origin(target):
+ if target.scheme != "https" or not target.hostname or target.username or target.password:
+ raise ValueError("Manifest origin must use HTTPS without credentials")
+ if (target.scheme, target.hostname, target.port or 443) != (origin.scheme, origin.hostname, origin.port or 443):
+ raise ValueError("Manifest is outside the expected release origin")
+
+ check_origin(location)
with opener(url, timeout=60) as response:
- if urlsplit(response.geturl()).scheme != "https":
- raise ValueError("Manifest redirected outside HTTPS")
+ check_origin(urlsplit(response.geturl()))
data = response.read(1024 * 1024 + 1)
if len(data) > 1024 * 1024:
raise ValueError("Release manifest exceeds size limit")
@@ -171,7 +180,8 @@ def transitions(env: dict) -> None:
candidate = read_candidate(env)
validate_candidates(candidate, tag, commit, base)
try:
- previous = read_manifest(env.get("BASELINE_MANIFEST_URL") or f"{base}/releases/stable/release-candidates.json")
+ previous = read_manifest(env.get("BASELINE_MANIFEST_URL") or f"{base}/releases/stable/release-candidates.json",
+ expected_origin=base)
except urllib.error.HTTPError as error:
if error.code == 404:
raise ValueError("No published stable package baseline. Supply baseline-manifest for an actual previous stable release; acceptance cannot be skipped.") from error
diff --git a/tests/scripts/test_stable_release.py b/tests/scripts/test_stable_release.py
index 88fe752db46..472b7f24198 100644
--- a/tests/scripts/test_stable_release.py
+++ b/tests/scripts/test_stable_release.py
@@ -38,6 +38,8 @@ def test_gate_requires_every_success_including_real_cli(tmp_path):
required = ["ci", "docker", "acceptance", "publication"]
success = {name: {"result": "success"} for name in required}
require_success(success, required)
+ with pytest.raises(ValueError, match="required-job list"):
+ require_success(success, [])
for name in required:
for result in ("failure", "cancelled", "skipped", None):
needs = copy.deepcopy(success)
@@ -51,6 +53,9 @@ def test_gate_requires_every_success_including_real_cli(tmp_path):
env = {**os.environ, "RELEASE_NEEDS": json.dumps(success), "GITHUB_STEP_SUMMARY": str(summary), "PYTHONPATH": str(ROOT)}
argv = [sys.executable, "-m", "scripts.releases.stable", "gate", *required]
assert subprocess.run(argv, cwd=tmp_path, env=env, capture_output=True).returncode == 0
+ empty = subprocess.run(argv[:4], cwd=tmp_path, env=env, capture_output=True, text=True, encoding="utf-8")
+ assert empty.returncode != 0
+ assert "required-job list" in empty.stderr
env["RELEASE_NEEDS"] = json.dumps({**success, "publication": {"result": "cancelled"}})
result = subprocess.run(argv, cwd=tmp_path, env=env, capture_output=True, text=True, encoding="utf-8")
assert result.returncode != 0
@@ -73,7 +78,7 @@ def test_transitions_bind_all_arches_identity_version_and_archive():
plan_transitions(old, missing, BASE)
with pytest.raises(ValueError, match="identity"):
validate_candidates(new, new["tag"], old["commit"], BASE)
- for key, value in [("commit", old["commit"]), ("identity", "different"), ("publisher", "CN=Other")]:
+ for key, value in [("commit", old["commit"]), ("identity", "different"), ("publisher", "CN=Other"), ("version", "9.9.9.0")]:
changed = copy.deepcopy(new)
changed["packages"][0][key] = value
with pytest.raises(ValueError):
@@ -91,6 +96,77 @@ def test_transitions_bind_all_arches_identity_version_and_archive():
plan_transitions(new, old, BASE)
+def test_manifest_origin_checks_with_real_https(tmp_path):
+ import datetime
+ import ipaddress
+ import ssl
+ import threading
+ import urllib.request
+ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
+
+ from cryptography import x509
+ from cryptography.hazmat.primitives import hashes, serialization
+ from cryptography.hazmat.primitives.asymmetric import rsa
+ from cryptography.x509.oid import NameOID
+
+ key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
+ name = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, "localhost")])
+ cert = (x509.CertificateBuilder().subject_name(name).issuer_name(name)
+ .public_key(key.public_key()).serial_number(x509.random_serial_number())
+ .not_valid_before(datetime.datetime(2020, 1, 1, tzinfo=datetime.timezone.utc))
+ .not_valid_after(datetime.datetime(2099, 1, 1, tzinfo=datetime.timezone.utc))
+ .add_extension(x509.SubjectAlternativeName([
+ x509.DNSName("localhost"), x509.IPAddress(ipaddress.ip_address("127.0.0.1")),
+ ]), critical=False).sign(key, hashes.SHA256()))
+ cert_file, key_file = tmp_path / "cert.pem", tmp_path / "key.pem"
+ cert_file.write_bytes(cert.public_bytes(serialization.Encoding.PEM))
+ key_file.write_bytes(key.private_bytes(serialization.Encoding.PEM,
+ serialization.PrivateFormat.PKCS8, serialization.NoEncryption()))
+ requests = []
+ data = b'{"schema":1}'
+
+ class Handler(BaseHTTPRequestHandler):
+ def do_GET(self):
+ requests.append(self.path)
+ if self.path in ("/same", "/cross"):
+ self.send_response(302)
+ host = "127.0.0.1" if self.path == "/same" else "localhost"
+ self.send_header("Location", f"https://{host}:{self.server.server_port}/manifest")
+ self.end_headers()
+ else:
+ self.send_response(200)
+ self.send_header("Content-Length", str(len(data)))
+ self.end_headers()
+ self.wfile.write(data)
+
+ def log_message(self, *args):
+ pass
+
+ server = ThreadingHTTPServer(("127.0.0.1", 0), Handler)
+ server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
+ server_context.load_cert_chain(cert_file, key_file)
+ server.socket = server_context.wrap_socket(server.socket, server_side=True)
+ client_context = ssl.create_default_context(cafile=str(cert_file))
+ opener = urllib.request.build_opener(urllib.request.ProxyHandler({}),
+ urllib.request.HTTPSHandler(context=client_context)).open
+ base = f"https://127.0.0.1:{server.server_port}"
+ thread = threading.Thread(target=server.serve_forever, daemon=True)
+ thread.start()
+ try:
+ digest = hashlib.sha256(data).hexdigest()
+ assert read_manifest(f"{base}/same", digest, expected_origin=base, opener=opener) == {"schema": 1}
+ with pytest.raises(ValueError, match="origin"):
+ read_manifest(f"{base}/cross", opener=opener)
+ requests.clear()
+ with pytest.raises(ValueError, match="origin"):
+ read_manifest(f"https://localhost:{server.server_port}/manifest", expected_origin=base, opener=opener)
+ assert requests == []
+ finally:
+ server.shutdown()
+ server.server_close()
+ thread.join(timeout=5)
+
+
def test_manifest_digest_and_tag_movement_fail_closed(tmp_path, monkeypatch):
data = b'{"schema":1}'