The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(release): record macOS channel artifacts without a release tag
ethernet68718cf6d3e0
diff --git a/scripts/bundles/release_artifacts.py b/scripts/bundles/release_artifacts.pyindex d831f3a90ad..2be63939e1b 100644--- a/scripts/bundles/release_artifacts.py+++ b/scripts/bundles/release_artifacts.py@@ -97,9 +97,10 @@ def record(platform: str, arch: str, root: Path, tag: str, commit: str, out: Patif stamp.get("receiverProtocol") == 1:row["receiverProtocol"] = 1elif platform == "macos":+ version = channel_request["version"] if channel_request is not None else tag[1:]package = single(root.glob(f"*-mac-{arch}.zip"))- if not package.name.endswith(f"-{tag[1:]}-mac-{arch}.zip"):- raise ValueError("macOS artifact filename differs from release tag")+ if not package.name.endswith(f"-{version}-mac-{arch}.zip"):+ raise ValueError("macOS artifact filename differs from requested version")app = single(root.glob("mac*/*.app"))subprocess.run(["codesign", "--verify", "--strict", str(app)], check=True)signature = subprocess.run(["codesign", "-dv", "--verbose=4", str(app)], check=True, capture_output=True, text=True, encoding="utf-8")@@ -113,8 +114,8 @@ def record(platform: str, arch: str, root: Path, tag: str, commit: str, out: Patif stamp.get("receiverProtocol") == 1:row["receiverProtocol"] = 1row.update(identity=info["CFBundleIdentifier"], teamId=team.group(1), version=info["CFBundleShortVersionString"], filename=package.name)- if row["version"] != (channel_request["version"] if channel_request else tag[1:]):- raise ValueError("App version differs from release tag")+ if row["version"] != version:+ raise ValueError("App version differs from requested version")elif platform == "termux":package = single((root / "deb").glob("*.deb"))fields = subprocess.check_output(["dpkg-deb", "--field", str(package), "Package", "Version", "Architecture"], text=True, encoding="utf-8")diff --git a/tests/scripts/test_macos_channel_artifact_record.py b/tests/scripts/test_macos_channel_artifact_record.pynew file mode 100644index 00000000000..2e4b5aa8d61--- /dev/null+++ b/tests/scripts/test_macos_channel_artifact_record.py@@ -0,0 +1,65 @@+"""Native artifact metadata stays bound to tagged or tagless package inputs."""+from __future__ import annotations++import json+import plistlib+import subprocess+import zipfile++import pytest++from scripts.bundles import release_artifacts+from tests.scripts.test_channel_build_versions import channel_request++[email protected]("arch", ["arm64", "x64"])[email protected]("channel", [False, True])+def test_macos_record_binds_filename_version_and_provenance(tmp_path, monkeypatch, arch, channel):+ commit = "a" * 40+ request = channel_request(commit, sequence=6) if channel else None+ tag = None if channel else "v1.2.3"+ version = request["version"] if request else "1.2.3"+ identity = request["identity"]["appId"] if request else "ai.hermes.test"+ stamp = ({"source": "channel-build", "channelBuild": request, "commit": commit, "tag": None}+ if request else {"commit": commit, "tag": tag, "baseVersion": version})+ root = tmp_path / "release"+ app = root / "mac" / "Product.app"+ app.mkdir(parents=True)+ package = root / f"Product-{version}-mac-{arch}.zip"+ out = root / "metadata.json"++ def write_package(app_version=version, package_stamp=stamp):+ with zipfile.ZipFile(package, "w") as archive:+ archive.writestr("Product.app/Contents/Info.plist", plistlib.dumps({+ "CFBundleIdentifier": identity, "CFBundleShortVersionString": app_version,+ }))+ archive.writestr("Product.app/Contents/Resources/install-stamp.json",+ json.dumps(package_stamp))++ def codesign(argv, **kwargs):+ assert argv[0] == "codesign"+ return subprocess.CompletedProcess(argv, 0, stderr="TeamIdentifier=ABCDEFGHIJ\n")++ monkeypatch.setattr(release_artifacts.subprocess, "run", codesign)+ write_package()+ original = package.read_bytes()+ release_artifacts.record("macos", arch, root, tag, commit, out, channel_request=request)+ metadata = json.loads(out.read_text(encoding="utf-8-sig"))+ assert metadata["identity"] == identity+ assert metadata["version"] == version+ assert metadata["filename"] == package.name+ assert metadata["teamId"] == "ABCDEFGHIJ"+ assert metadata.get("request") == request+ assert package.read_bytes() == original++ wrong_name = package.with_name(f"Product-9.9.9-mac-{arch}.zip")+ package.rename(wrong_name)+ with pytest.raises(ValueError, match="filename"):+ release_artifacts.record("macos", arch, root, tag, commit, out, channel_request=request)+ wrong_name.rename(package)+ write_package(app_version="9.9.9")+ with pytest.raises(ValueError, match="version"):+ release_artifacts.record("macos", arch, root, tag, commit, out, channel_request=request)+ write_package(package_stamp={**stamp, "commit": "b" * 40})+ with pytest.raises(ValueError, match="provenance"):+ release_artifacts.record("macos", arch, root, tag, commit, out, channel_request=request)