Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
ci(spaces): per-platform patch releases (CUA-2068) (#5731)
Francesco Bonacci934ebb0e27e8
diff --git a/.github/scripts/spaces_platforms.py b/.github/scripts/spaces_platforms.pynew file mode 100644index 0000000000..dd5f2fd386--- /dev/null+++ b/.github/scripts/spaces_platforms.py@@ -0,0 +1,248 @@+#!/usr/bin/env python3+"""Per-platform patch releases for Cua Spaces (CUA-2068, design trycua/cua#5704).++Two subcommands, both used by .github/workflows/cd-cua-spaces.yml.++plan Decide which platforms (macos, windows, linux) a stable release builds+ and publishes, from the paths changed since the previous published+ stable release tag. Prints key=value lines (--github-output also appends them to $GITHUB_OUTPUT).++ spaces_platforms.py plan --previous cua-spaces-v0.13.0 [--head HEAD]+ spaces_platforms.py plan --manual windows,linux --reason "..."+ spaces_platforms.py plan --force-all "prerelease"++ The default is ALL platforms. A subset is chosen only when every changed+ path is classified: shared code, an unknown path, no previous tag, a+ prerelease, a Sparkle cutover or any doubt means all.++notes Print the release-notes paragraph that says which platforms a release+ contains and which version each skipped platform stays on.++ spaces_platforms.py notes --platforms macos --manifest release-artifacts.json++Path rules (first match wins; see classify()):+ neutral docs, Markdown, desktop tests, and the version-only edits that+ Release Please makes to its own files. They never pick a platform.+ macos apps/cua-spaces-macos/**, and the Electron macOS signing and+ Sparkle files.+ windows the NSIS installer script.+ linux the Linux packaging files (prerm, icons, tray, permissions, polkit).+ all anything else: libs/cua/**, the renderer and main process in+ apps/cua-spaces-desktop/src/**, the web UI, the cua-spacesd pin,+ the release workflow and every path not listed above.+"""++from __future__ import annotations++import argparse+import json+import os+import re+import subprocess+import sys+from pathlib import Path++OSES = ("macos", "windows", "linux")+ALL, NEUTRAL = "all", "neutral"++# Files Release Please edits on a release PR. Neutral only when the diff is a+# version bump (see version_only). The cua-spacesd pin (libs/cua-spacesd/VERSION)+# is deliberately not here: it changes what every platform bundles.+RELEASE_BUMP_FILES = {+ ".release-please-manifest.json",+ "apps/cua-spaces-macos/VERSION",+ "apps/cua-spaces-macos/Support/Info.plist",+ "apps/cua-spaces-desktop/package.json",+ "apps/cua-spaces/package.json",+ "apps/cua-spaces/src-tauri/tauri.conf.json",+ "apps/cua-spaces/src-tauri/Cargo.toml",+ "apps/cua-spaces/src-tauri/Cargo.lock",+}++D = "apps/cua-spaces-desktop/"+NEUTRAL_PATTERNS = (+ r".*\.mdx?$",+ r"docs/",+ D + r"docs/",+ D + r"test/",+ r"apps/cua-spaces-macos/(Tests|UITests)/",+)+MACOS_PATTERNS = (+ r"apps/cua-spaces-macos/",+ D + r"packaging/entitlements\.mac[^/]*\.plist$",+ D + r"packaging/sign-mac\.cjs$",+ D + r"scripts/sparkle/",+)+WINDOWS_PATTERNS = (D + r"packaging/installer\.nsh$",)+LINUX_PATTERNS = (+ D + r"packaging/linux/",+ D + r"packaging/linux-icons/",+ D + r"packaging/linux-tray/",+ D + r"packaging/linux-permissions\.cjs$",+ D + r"packaging/ai\.cua\.spaces\.policy$",+)++# A changed line that is only a version number: `"version": "1.2.3",`,+# `<string>1.2.3</string>`, `1.2.3`, a manifest entry `"path": "1.2.3"`,+# a Cargo `version = "1.2.3"`.+VERSION_LINE = re.compile(+ r'^[+-]\s*(?:"[\w@./-]+"\s*[:=]\s*|version\s*=\s*)?"?(?:<string>)?'+ r"\d+\.\d+\.\d+[-+.0-9A-Za-z]*(?:</string>)?\"?,?\s*$"+)+++def version_only_diff(diff: str) -> bool:+ """True when every changed line of a unified diff is a version number."""+ changed = [+ line for line in diff.splitlines()+ if line[:1] in "+-" and not line.startswith(("+++", "---"))+ ]+ return bool(changed) and all(VERSION_LINE.match(line) for line in changed)+++def classify(path: str, version_only=lambda p: False) -> str:+ """One of OSES, NEUTRAL or ALL for a changed repo-relative path."""+ for pattern in NEUTRAL_PATTERNS:+ if re.match(pattern, path):+ return NEUTRAL+ if path in RELEASE_BUMP_FILES and version_only(path):+ return NEUTRAL+ for os_name, patterns in (("macos", MACOS_PATTERNS), ("windows", WINDOWS_PATTERNS), ("linux", LINUX_PATTERNS)):+ if any(re.match(p, path) for p in patterns):+ return os_name+ return ALL+++def decide(paths: list[str], version_only=lambda p: False) -> tuple[list[str], str]:+ """(platforms, reason) for the changed paths. Doubt means all three."""+ everything = list(OSES)+ if not paths:+ return everything, "no changed paths found: all platforms"+ picked: set[str] = set()+ for path in paths:+ kind = classify(path, version_only)+ if kind == ALL:+ return everything, f"{path} is shared or not classified: all platforms"+ if kind != NEUTRAL:+ picked.add(kind)+ if not picked:+ return everything, "only documentation or version bumps changed: all platforms (nothing to narrow on)"+ chosen = [o for o in OSES if o in picked]+ return chosen, "only " + ", ".join(chosen) + " paths changed"+++def parse_platforms(value: str) -> list[str]:+ names = [n.strip().lower() for n in value.split(",") if n.strip()]+ if not names or names == ["all"]:+ return list(OSES)+ bad = [n for n in names if n not in OSES]+ if bad:+ raise SystemExit(f"bad platforms {bad}: use all or a comma list of {', '.join(OSES)}")+ return [o for o in OSES if o in names]+++def git(*args: str) -> str:+ return subprocess.run(["git", *args], check=True, capture_output=True, text=True).stdout+++def changed_paths(previous: str, head: str) -> list[str]:+ return [p for p in git("diff", "--name-only", f"{previous}...{head}").splitlines() if p]+++def plan(args: argparse.Namespace) -> dict:+ if args.manual and args.manual.strip().lower() != "all":+ platforms = parse_platforms(args.manual)+ if not (args.reason or "").strip():+ raise SystemExit("a manual platforms list needs a reason (platforms_reason)")+ reason = f"manual: {args.reason.strip()}"+ elif args.force_all:+ platforms, reason = list(OSES), f"all platforms: {args.force_all}"+ elif not args.previous:+ platforms, reason = list(OSES), "no previous stable release to compare with: all platforms"+ else:+ try:+ paths = changed_paths(args.previous, args.head)+ platforms, reason = decide(+ paths, lambda p: version_only_diff(git("diff", "-U0", f"{args.previous}...{args.head}", "--", p))+ )+ except subprocess.CalledProcessError as error:+ platforms, reason = list(OSES), f"could not diff against {args.previous} ({error.returncode}): all platforms"+ return {+ **{o: str(o in platforms).lower() for o in OSES},+ "platforms": ",".join(platforms),+ "partial": str(len(platforms) < len(OSES)).lower(),+ "reason": reason,+ }+++def manifest_versions(manifest: dict, component: str = "app") -> dict[str, str]:+ """OS -> the version install.sh / install.ps1 would install there."""+ found: dict[str, str] = {}+ for artifact in manifest.get("artifacts", []):+ if artifact.get("component") != component:+ continue+ prefix = artifact.get("platform", "").split("-")[0]+ os_name = {"darwin": "macos", "windows": "windows", "linux": "linux"}.get(prefix)+ if os_name:+ found.setdefault(os_name, artifact.get("version", ""))+ return found+++LABEL = {"macos": "macOS", "windows": "Windows", "linux": "Linux"}+++def join_names(names: list[str]) -> str:+ labels = [LABEL[n] for n in names]+ return labels[0] if len(labels) == 1 else ", ".join(labels[:-1]) + " and " + labels[-1]+++def notes(platforms: list[str], manifest: dict) -> str:+ skipped = [o for o in OSES if o not in platforms]+ if not skipped:+ return ""+ versions = manifest_versions(manifest)+ lines = [f"**Platforms in this release:** {join_names(platforms)} only."]+ detail = []+ for o in skipped:+ detail.append(f"{LABEL[o]} stays on {versions[o]}" if versions.get(o) else f"{LABEL[o]} is unchanged")+ lines.append(+ "; ".join(detail)+ + ". Those installers and update feeds still point at the earlier build, so "+ + join_names(skipped)+ + " users are not offered this update."+ )+ return "\n\n".join(lines) + "\n"+++def write_outputs(outputs: dict, github_output: bool) -> None:+ lines = "".join(f"{k}={v}\n" for k, v in outputs.items())+ target = os.environ.get("GITHUB_OUTPUT")+ if github_output and target:+ with open(target, "a") as handle:+ handle.write(lines)+ sys.stdout.write(lines)+++def main(argv: list[str] | None = None) -> int:+ parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)+ sub = parser.add_subparsers(dest="command", required=True)+ p = sub.add_parser("plan")+ p.add_argument("--previous", default="", help="previous published stable release tag")+ p.add_argument("--head", default="HEAD")+ p.add_argument("--manual", default="", help="manual platforms input (all or a comma list)")+ p.add_argument("--reason", default="", help="why, for a manual list")+ p.add_argument("--force-all", default="", help="build everything, with this reason")+ p.add_argument("--github-output", action="store_true", help="also append the outputs to $GITHUB_OUTPUT")+ n = sub.add_parser("notes")+ n.add_argument("--platforms", required=True)+ n.add_argument("--manifest", required=True)+ args = parser.parse_args(argv)+ if args.command == "plan":+ write_outputs(plan(args), args.github_output)+ else:+ sys.stdout.write(notes(parse_platforms(args.platforms), json.loads(Path(args.manifest).read_text())))+ return 0+++if __name__ == "__main__":+ sys.exit(main())diff --git a/.github/scripts/tests/test_cua_sdk_release_repository.py b/.github/scripts/tests/test_cua_sdk_release_repository.pyindex f031a2b843..0b476bd84a 100644--- a/.github/scripts/tests/test_cua_sdk_release_repository.py+++ b/.github/scripts/tests/test_cua_sdk_release_repository.py@@ -102,7 +102,11 @@ def test_spaces_releases_macos_only_for_now() -> None:# The Tauri Linux/Windows job is kept but off unless explicitly enabled.assert jobs["build-linux-windows"]["if"] == "vars.CUA_SPACES_LINUX_WINDOWS == 'true'"# The SwiftUI app builds on every release; only an Electron dry run skips it.- assert jobs["build-macos"]["if"] == "github.event_name != 'workflow_dispatch' || !inputs.electron_dry_run"+ # A release without macOS (a Windows or Linux patch) skips it too.+ assert jobs["build-macos"]["if"] == (+ "(github.event_name != 'workflow_dispatch' || !inputs.electron_dry_run) "+ "&& needs.electron-plan.outputs.macos == 'true'"+ )# Publishing runs with the Tauri job skipped, never after it failed.gate = jobs["installer-manifest"]["if"]assert "!cancelled()" in gate@@ -133,11 +137,15 @@ def test_spaces_electron_builds_only_for_prereleases_and_dry_runs() -> None:assert '[ "$DRY_RUN" != true ]' in plan and "refs/tags/cua-spaces-v*" in planassert jobs["electron-mac"]["if"] == "needs.electron-plan.outputs.build == 'true'"# Windows and Linux build for every release tag, stable included.- for name in ("electron-native", "electron-windows", "electron-linux"):- assert jobs[name]["if"] == "needs.electron-plan.outputs.desktop == 'true'", name+ # (a partial release builds only the platforms it changed).+ assert jobs["electron-native"]["if"] == "needs.electron-plan.outputs.desktop == 'true'"+ for name, platform in (("electron-windows", "windows"), ("electron-linux", "linux")):+ want = f"needs.electron-plan.outputs.desktop == 'true' && needs.electron-plan.outputs.{platform} == 'true'"+ assert jobs[name]["if"] == want, namepublish_gate = jobs["electron-publish"]["if"]- assert "needs.electron-plan.outputs.publish == 'true'" in publish_gate- assert "needs.electron-windows.result == 'success' && needs.electron-linux.result == 'success'" in publish_gate+ assert "needs.electron-plan.outputs.publish_electron == 'true'" in publish_gate+ assert "(needs.electron-plan.outputs.windows != 'true' || needs.electron-windows.result == 'success')" in publish_gate+ assert "(needs.electron-plan.outputs.linux != 'true' || needs.electron-linux.result == 'success')" in publish_gate# Each build runs the native and notch interfaces before electron-builder.mac = "\n".join(s.get("run", "") for s in steps("cd-cua-spaces.yml", "electron-mac"))assert "pnpm native -- --target aarch64-apple-darwin" in mac@@ -159,8 +167,9 @@ def test_spaces_electron_builds_only_for_prereleases_and_dry_runs() -> None:assert mac.index("xcrun stapler staple") < mac.index("refresh-update-info.mjs") < mac.index("spctl -a -vv -t install")assert "com.trycua.spaces.macos" in macwindows = "\n".join(s.get("run", "") for s in steps("cd-cua-spaces.yml", "electron-windows-pkg"))- targets = {m["target"] for m in jobs["electron-native"]["strategy"]["matrix"]["include"]}- assert {"x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc"} <= targets+ # The native matrix comes from the plan step, one entry per platform built.+ assert jobs["electron-native"]["strategy"]["matrix"]["include"] == "${{ fromJSON(needs.electron-plan.outputs.native_matrix) }}"+ assert "x86_64-pc-windows-msvc" in plan and "aarch64-pc-windows-msvc" in planassert 'AZURE_SIGNING_ENDPOINT="$ENDPOINT"' in windowsassert jobs["electron-windows-pkg"]["environment"] == "cua-driver-release-signing"for name in ("electron-mac", "electron-windows-pkg"):@@ -168,7 +177,7 @@ def test_spaces_electron_builds_only_for_prereleases_and_dry_runs() -> None:assert 'elif [ "$REQUIRE_SIGNING" = true ]; then' in sign, name# The release waits for the Electron installers; the feed goes up after it is published.gate = jobs["installer-manifest"]["if"]- assert "needs.electron-plan.outputs.publish != 'true' || needs.electron-publish.result == 'success'" in gate+ assert "needs.electron-plan.outputs.publish_electron != 'true' || needs.electron-publish.result == 'success'" in gatenames = [s.get("name") for s in steps("cd-cua-spaces.yml", "installer-manifest")]assert names.index("Publish the release") < names.index("Upload the Electron feed to cua-spaces-latest")publish = step("cd-cua-spaces.yml", "electron-publish", "Upload the installers and ready the feed")["run"]@@ -198,7 +207,7 @@ def test_spaces_prereleases_never_become_latest_or_move_canonical_feeds() -> Nonassert "--prerelease --latest=false" in publishassert "UNSIGNED" in publishfeeds = step("cd-cua-spaces.yml", "installer-manifest", "Update the rolling feeds")- assert feeds["if"] == "needs.build-macos.outputs.prerelease != 'true' || github.repository != 'trycua/cua'"+ assert feeds["if"] == "needs.electron-plan.outputs.prerelease != 'true' || github.repository != 'trycua/cua'"def test_sdk_registries_publish_only_from_trycua_cua() -> None:diff --git a/.github/scripts/tests/test_spaces_platforms.py b/.github/scripts/tests/test_spaces_platforms.pynew file mode 100644index 0000000000..d655d83557--- /dev/null+++ b/.github/scripts/tests/test_spaces_platforms.py@@ -0,0 +1,181 @@+"""Platform planner and release notes for per-platform Spaces patches (CUA-2068)."""++import json+import subprocess+import sys+import tempfile+import unittest+from pathlib import Path++sys.path.insert(0, str(Path(__file__).resolve().parents[1]))+import spaces_platforms as sp # noqa: E402++D = "apps/cua-spaces-desktop/"+BUMPS = [+ ".release-please-manifest.json",+ "apps/cua-spaces-macos/VERSION",+ "apps/cua-spaces-macos/CHANGELOG.md",+ "apps/cua-spaces-macos/Support/Info.plist",+ D + "package.json",+ "apps/cua-spaces/src-tauri/Cargo.lock",+]+++def decide(paths, bumps_are_version_only=True):+ return sp.decide(paths, lambda p: bumps_are_version_only)[0]+++class Decide(unittest.TestCase):+ def test_macos_only(self):+ self.assertEqual(decide(["apps/cua-spaces-macos/Sources/App.swift"]), ["macos"])++ def test_macos_with_release_bump_files_is_still_macos_only(self):+ self.assertEqual(decide(["apps/cua-spaces-macos/Sources/App.swift", *BUMPS]), ["macos"])++ def test_windows_and_linux_packaging(self):+ self.assertEqual(decide([D + "packaging/installer.nsh"]), ["windows"])+ self.assertEqual(decide([D + "packaging/linux/prerm.sh"]), ["linux"])+ self.assertEqual(decide([D + "packaging/linux/prerm.sh", D + "packaging/installer.nsh"]), ["windows", "linux"])+ self.assertEqual(decide([D + "packaging/installer.nsh", "apps/cua-spaces-macos/VERSION"]), ["windows"])++ def test_shared_paths_mean_all(self):+ for path in (+ "libs/cua/crates/cua-sdk/src/lib.rs",+ D + "src/main.ts",+ D + "src/model/spaces.ts",+ "apps/cua-spaces-web/src/App.tsx",+ "libs/cua-spacesd/VERSION",+ D + "electron-builder.config.cjs",+ D + "pnpm-lock.yaml",+ ".github/workflows/cd-cua-spaces.yml",+ ):+ self.assertEqual(decide([path]), list(sp.OSES), path)++ def test_one_shared_path_among_platform_paths_means_all(self):+ self.assertEqual(decide(["apps/cua-spaces-macos/Sources/A.swift", "libs/cua/Cargo.toml"]), list(sp.OSES))++ def test_unknown_path_means_all(self):+ self.assertEqual(decide(["scripts/brand-new-dir/thing.sh"]), list(sp.OSES))++ def test_nothing_or_neutral_only_means_all(self):+ self.assertEqual(sp.decide([])[0], list(sp.OSES))+ self.assertEqual(decide(["docs/a.mdx", "README.md", *BUMPS]), list(sp.OSES))++ def test_a_real_edit_to_a_bump_file_is_not_neutral(self):+ # Info.plist changed beyond the version: macOS owns it. package.json+ # beyond the version: shared.+ self.assertEqual(decide(["apps/cua-spaces-macos/Support/Info.plist"], False), ["macos"])+ self.assertEqual(decide([D + "package.json", "apps/cua-spaces-macos/Sources/A.swift"], False), list(sp.OSES))++ def test_desktop_tests_and_docs_are_neutral(self):+ self.assertEqual(decide([D + "test/teams.test.ts", D + "docs/x.md", D + "packaging/installer.nsh"]), ["windows"])++ def test_electron_mac_signing_is_macos(self):+ self.assertEqual(decide([D + "packaging/sign-mac.cjs", D + "packaging/entitlements.mac.plist"]), ["macos"])+++class VersionOnly(unittest.TestCase):+ def test_json_bump(self):+ self.assertTrue(sp.version_only_diff('- "version": "0.13.0",\n+ "version": "0.13.1",\n'))++ def test_plist_and_bare_version(self):+ self.assertTrue(sp.version_only_diff("-\t<string>0.13.0</string>\n+\t<string>0.13.1</string>\n"))+ self.assertTrue(sp.version_only_diff("-0.13.0\n+0.13.1\n"))++ def test_manifest_and_cargo(self):+ self.assertTrue(sp.version_only_diff('- "apps/cua-spaces-macos": "0.13.0"\n+ "apps/cua-spaces-macos": "0.13.1"\n'))+ self.assertTrue(sp.version_only_diff('-version = "0.13.0"\n+version = "0.13.1"\n'))++ def test_other_edits_are_not_version_only(self):+ self.assertFalse(sp.version_only_diff('- "version": "0.13.0",\n+ "version": "0.13.1",\n+ "scripts": {},\n'))+ self.assertFalse(sp.version_only_diff(""))+++class Manual(unittest.TestCase):+ def args(self, **kw):+ base = dict(previous="", head="HEAD", manual="", reason="", force_all="")+ base.update(kw)+ return type("A", (), base)++ def test_manual_needs_reason(self):+ with self.assertRaises(SystemExit):+ sp.plan(self.args(manual="macos"))+ out = sp.plan(self.args(manual="macos", reason="notarization hotfix"))+ self.assertEqual((out["macos"], out["windows"], out["linux"], out["partial"]), ("true", "false", "false", "true"))+ self.assertIn("notarization hotfix", out["reason"])++ def test_manual_all_needs_no_reason(self):+ self.assertEqual(sp.plan(self.args(manual="all"))["partial"], "false")++ def test_bad_name(self):+ with self.assertRaises(SystemExit):+ sp.plan(self.args(manual="macos,beos", reason="x"))++ def test_defaults_to_all(self):+ self.assertEqual(sp.plan(self.args())["platforms"], "macos,windows,linux")+ self.assertEqual(sp.plan(self.args(force_all="prerelease"))["partial"], "false")+ self.assertEqual(sp.plan(self.args(previous="no-such-tag-xyz"))["partial"], "false")+++class GitPlan(unittest.TestCase):+ """The planner end to end against a throwaway repository."""++ def run_git(self, *args):+ subprocess.run(["git", "-C", self.repo, *args], check=True, capture_output=True)++ def write(self, path, text):+ file = Path(self.repo) / path+ file.parent.mkdir(parents=True, exist_ok=True)+ file.write_text(text)++ def test_mac_fix_after_a_release(self):+ with tempfile.TemporaryDirectory() as repo:+ self.repo = repo+ self.run_git("init", "-q", "-b", "main")+ self.run_git("config", "user.email", "[email protected]")+ self.run_git("config", "user.name", "t")+ self.write("apps/cua-spaces-macos/VERSION", "0.13.0\n")+ self.write(D + "package.json", '{\n "name": "x",\n "version": "0.13.0"\n}\n')+ self.write(D + "src/main.ts", "a\n")+ self.run_git("add", "-A")+ self.run_git("commit", "-qm", "release 0.13.0")+ self.run_git("tag", "cua-spaces-v0.13.0")+ self.write("apps/cua-spaces-macos/Sources/A.swift", "fix\n")+ self.write("apps/cua-spaces-macos/VERSION", "0.13.1\n")+ self.write(D + "package.json", '{\n "name": "x",\n "version": "0.13.1"\n}\n')+ self.run_git("add", "-A")+ self.run_git("commit", "-qm", "mac fix and bump")+ cwd = Path.cwd()+ try:+ import os+ os.chdir(repo)+ out = sp.plan(type("A", (), dict(previous="cua-spaces-v0.13.0", head="HEAD", manual="", reason="", force_all="")))+ self.assertEqual(out["platforms"], "macos")+ self.write(D + "src/main.ts", "b\n")+ self.run_git("add", "-A")+ self.run_git("commit", "-qm", "renderer change")+ out = sp.plan(type("A", (), dict(previous="cua-spaces-v0.13.0", head="HEAD", manual="", reason="", force_all="")))+ self.assertEqual(out["platforms"], "macos,windows,linux")+ finally:+ os.chdir(cwd)+++class Notes(unittest.TestCase):+ MANIFEST = {"artifacts": [+ {"component": "app", "platform": "darwin-arm64", "version": "0.13.1"},+ {"component": "app", "platform": "windows-x64", "version": "0.13.0"},+ {"component": "app", "platform": "linux-x64", "version": "0.12.2"},+ ]}++ def test_partial(self):+ text = sp.notes(["macos"], self.MANIFEST)+ self.assertIn("**Platforms in this release:** macOS only.", text)+ self.assertIn("Windows stays on 0.13.0; Linux stays on 0.12.2", text)+ self.assertIn("Windows and Linux users are not offered this update", text)++ def test_full_release_has_no_block(self):+ self.assertEqual(sp.notes(list(sp.OSES), self.MANIFEST), "")+++if __name__ == "__main__":+ unittest.main()diff --git a/.github/workflows/cd-cua-spaces.yml b/.github/workflows/cd-cua-spaces.ymlindex 3e2161fd8a..357105489f 100644--- a/.github/workflows/cd-cua-spaces.yml+++ b/.github/workflows/cd-cua-spaces.yml@@ -129,6 +129,20 @@ name: "CD: Cua Spaces"# of the SwiftUI app's, so installed Swift apps update to the Electron app.# It refuses to run unless src/updater.ts serves the stable feed.#+# Platform patch releases (CUA-2068, design trycua/cua#5704). One version line,+# but a stable release only builds and publishes the platforms whose inputs+# changed since the previous published stable release (electron-plan, with+# .github/scripts/spaces_platforms.py): apps/cua-spaces-macos/** alone ships+# macOS only; Windows or Linux packaging files alone ship that platform; shared+# code (libs/cua, the renderer, the web UI, the cua-spacesd pin), the release+# workflow, any unlisted path, a prerelease, the Sparkle cutover and any doubt+# ship all three. A manual run can set `platforms` with a `platforms_reason`.+# A skipped platform is not built or copied; its feeds (latest.yml,+# latest-linux*.yml) are not touched; the Sparkle appcast gets an item only when+# macOS ships; release-artifacts.json keeps its previous artifacts (each with its+# own version) so install.sh and install.ps1 install the newest build per+# platform; the release notes name the platforms. Everything defaults to all.+## Build speed (a release is a critical path of the slowest job):# - Native libraries are built per target in parallel and kept in the Actions# cache by the git tree hash of their inputs (.github/actions/spaces-native,@@ -180,6 +194,14 @@ on:description: "Sparkle cutover (once, see apps/cua-spaces-desktop/docs/sparkle-cutover.md): this release's Sparkle item is the Electron app"type: booleandefault: false+ platforms:+ description: "Platforms to build and publish: all (default) or a comma list of macos, windows, linux (needs platforms_reason)"+ required: false+ default: "all"+ platforms_reason:+ description: "Why only these platforms (required unless platforms is all)"+ required: false+ default: ""skip_staging_gate:description: "BREAK-GLASS: publish without a green staging smoke for this commit (needs skip_staging_reason; logged loudly)"type: boolean@@ -245,8 +267,10 @@ jobs:# builds.macos-rust:name: SwiftUI Rust (${{ matrix.arch }})- needs: spacesd-published- if: github.event_name != 'workflow_dispatch' || !inputs.electron_dry_run+ needs: [spacesd-published, electron-plan]+ if: >-+ (github.event_name != 'workflow_dispatch' || !inputs.electron_dry_run)+ && needs.electron-plan.outputs.macos == 'true'runs-on: macos-26timeout-minutes: 180defaults:@@ -277,8 +301,11 @@ jobs:build-macos:name: darwin-universal (SwiftUI)needs: [spacesd-published, electron-plan, macos-rust, electron-web]- # An Electron dry run builds only the Electron app.- if: github.event_name != 'workflow_dispatch' || !inputs.electron_dry_run+ # An Electron dry run builds only the Electron app; a release without+ # macOS (a Windows or Linux patch) skips the SwiftUI app.+ if: >-+ (github.event_name != 'workflow_dispatch' || !inputs.electron_dry_run)+ && needs.electron-plan.outputs.macos == 'true'runs-on: macos-26timeout-minutes: 180defaults:@@ -864,18 +891,34 @@ jobs:defaults:run:working-directory: .+ permissions:+ contents: readoutputs:version: ${{ steps.plan.outputs.version }}+ prerelease: ${{ steps.plan.outputs.prerelease }}build: ${{ steps.plan.outputs.build }}desktop: ${{ steps.plan.outputs.desktop }}publish: ${{ steps.plan.outputs.publish }}+ publish_electron: ${{ steps.plan.outputs.publish_electron }}cutover: ${{ steps.plan.outputs.cutover }}+ macos: ${{ steps.plan.outputs.macos }}+ windows: ${{ steps.plan.outputs.windows }}+ linux: ${{ steps.plan.outputs.linux }}+ partial: ${{ steps.plan.outputs.partial }}+ platforms: ${{ steps.plan.outputs.platforms }}+ native_matrix: ${{ steps.plan.outputs.native_matrix }}steps:- uses: actions/checkout@v4+ with:+ # The path diff against the previous release tag.+ fetch-depth: 0- name: Planid: planenv:+ GH_TOKEN: ${{ github.token }}EVENT: ${{ github.event_name }}+ INPUT_PLATFORMS: ${{ github.event_name == 'workflow_dispatch' && inputs.platforms || 'all' }}+ INPUT_PLATFORMS_REASON: ${{ github.event_name == 'workflow_dispatch' && inputs.platforms_reason || '' }}INPUT_VERSION: ${{ inputs.version }}DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.electron_dry_run }}SPARKLE_INPUT: ${{ github.event_name == 'workflow_dispatch' && inputs.sparkle_electron }}@@ -903,14 +946,94 @@ jobs:# Any release tag publishes; a dry run never does.publish=falseif [ "$DRY_RUN" != true ] && [[ "$GITHUB_REF" == refs/tags/cua-spaces-v* ]]; then publish=true; fi+ # A semver prerelease, or any build off the canonical repository,+ # is a GitHub prerelease (never "latest").+ prerelease=false+ if [[ "$VERSION" == *-* || "$GITHUB_REPOSITORY" != trycua/cua ]]; then prerelease=true; fi++ # Platforms (CUA-2068). Default: all three. Narrowed only by a manual+ # list with a reason, or (stable tag, trycua/cua only) when every path+ # changed since the previous published stable release is classified.+ # A prerelease, the Sparkle cutover and any doubt build everything.+ force=""+ if [ "$cutover" = true ]; then force="Sparkle cutover"+ elif [ "$beta" = true ]; then force="prerelease"+ elif [ "$EVENT" != workflow_dispatch ] && [ "$GITHUB_REPOSITORY" != trycua/cua ]; then force="not trycua/cua"+ fi+ previous=""+ if [ -z "$force" ] && [ "$EVENT" != workflow_dispatch ]; then+ # The newest published (not draft, not pre-) stable release below this one.+ published="$(gh release list --repo "$GITHUB_REPOSITORY" --exclude-drafts --exclude-pre-releases \+ --limit 100 --json tagName --jq '.[].tagName' | grep '^cua-spaces-v[0-9.]*$' \+ | grep -vx "cua-spaces-v$VERSION" || true)"+ previous="$(printf '%s\n%s\n' "$published" "cua-spaces-v$VERSION" | grep . | sort -V \+ | grep -x -B1 "cua-spaces-v$VERSION" | head -n 1)"+ [ "$previous" = "cua-spaces-v$VERSION" ] && previous=""+ fi+ # The manual list wins over everything but the cutover and a prerelease.+ manual="$INPUT_PLATFORMS"; [ -n "$force" ] && manual=all+ python3 .github/scripts/spaces_platforms.py plan --previous "$previous" --manual "$manual" \+ --reason "$INPUT_PLATFORMS_REASON" ${force:+--force-all "$force"} > plan.txt+ cat plan.txt+ macos="$(sed -n 's/^macos=//p' plan.txt)"+ win="$(sed -n 's/^windows=//p' plan.txt)"+ lin="$(sed -n 's/^linux=//p' plan.txt)"+ reason="$(sed -n 's/^reason=//p' plan.txt)"+ # macOS Electron (`build`) rides on macOS; Windows and Linux on `desktop`.+ [ "$macos" = true ] || build=false+ { [ "$win" = true ] || [ "$lin" = true ]; } || desktop=false+ [ "$desktop" = true ] || { win=false; lin=false; }+ [ "$macos" != true ] && [ "$desktop" != true ] && { echo "::error::none of the chosen platforms ($(sed -n 's/^platforms=//p' plan.txt)) can be built in this run: Windows and Linux build on a release tag or an electron_dry_run, macOS on any non-dry run"; exit 1; }+ platforms=""+ [ "$macos" = true ] && platforms="macos"+ [ "$win" = true ] && platforms="${platforms:+$platforms,}windows"+ [ "$lin" = true ] && platforms="${platforms:+$platforms,}linux"+ partial=false; [ "$platforms" != "macos,windows,linux" ] && partial=true+ # Native libraries: only the targets of the platforms being built.+ python3 - "$win" "$lin" > matrix.json <<'PY'+ import json, sys+ win, lin = sys.argv[1] == "true", sys.argv[2] == "true"+ include = []+ if win:+ include += [+ {"label": "win32-x64", "runner": "windows-latest", "target": "x86_64-pc-windows-msvc"},+ {"label": "win32-arm64", "runner": "windows-11-arm", "target": "aarch64-pc-windows-msvc"},+ ]+ if lin:+ include += [+ {"label": "linux-x64", "runner": "ubuntu-22.04", "target": "x86_64-unknown-linux-gnu"},+ {"label": "linux-arm64", "runner": "ubuntu-22.04-arm", "target": "aarch64-unknown-linux-gnu"},+ ]+ print(json.dumps(include, separators=(",", ":")))+ PY+ matrix="$(cat matrix.json)"+ publish_electron=false; { [ "$publish" = true ] && [ "$desktop" = true ]; } && publish_electron=true{echo "version=$VERSION"+ echo "prerelease=$prerelease"echo "build=$build"echo "desktop=$desktop"echo "publish=$publish"+ echo "publish_electron=$publish_electron"echo "cutover=$cutover"+ echo "macos=$macos"+ echo "windows=$win"+ echo "linux=$lin"+ echo "partial=$partial"+ echo "platforms=$platforms"+ echo "native_matrix=$matrix"} >> "$GITHUB_OUTPUT"echo "Electron: version $VERSION, build(mac)=$build, desktop(win+linux)=$desktop, publish=$publish, Sparkle cutover=$cutover"+ echo "Platforms: $platforms (partial=$partial; previous release ${previous:-none}): $reason"+ {+ echo "### Platforms in this release: $platforms"+ echo+ echo "$reason (previous stable release: ${previous:-none})"+ if [ "$partial" = true ]; then+ echo+ echo "Skipped platforms are not rebuilt, and their update feeds are not touched."+ fi+ } >> "$GITHUB_STEP_SUMMARY"# The web UI (the app core compiled to wasm, and the Vite build), built once# for every job that bundles it: the SwiftUI app, the Electron apps.@@ -974,11 +1097,9 @@ jobs:strategy:fail-fast: falsematrix:- include:- - { label: win32-x64, runner: windows-latest, target: x86_64-pc-windows-msvc }- - { label: win32-arm64, runner: windows-11-arm, target: aarch64-pc-windows-msvc }- - { label: linux-x64, runner: ubuntu-22.04, target: x86_64-unknown-linux-gnu }- - { label: linux-arm64, runner: ubuntu-22.04-arm, target: aarch64-unknown-linux-gnu }+ # The targets of the Windows and Linux platforms being built+ # (electron-plan; all four unless a patch release skips one).+ include: ${{ fromJSON(needs.electron-plan.outputs.native_matrix) }}defaults:run:working-directory: apps/cua-spaces-desktop@@ -1308,7 +1429,7 @@ jobs:electron-windows-pkg:name: Electron windows (${{ matrix.arch }})needs: [electron-plan, electron-native, electron-web]- if: needs.electron-plan.outputs.desktop == 'true'+ if: needs.electron-plan.outputs.desktop == 'true' && needs.electron-plan.outputs.windows == 'true'runs-on: windows-latesttimeout-minutes: 120strategy:@@ -1438,7 +1559,7 @@ jobs:electron-windows:name: Electron windows (x64, arm64)needs: [electron-plan, electron-windows-pkg]- if: needs.electron-plan.outputs.desktop == 'true'+ if: needs.electron-plan.outputs.desktop == 'true' && needs.electron-plan.outputs.windows == 'true'runs-on: ubuntu-latesttimeout-minutes: 15permissions:@@ -1490,7 +1611,7 @@ jobs:electron-linux-pkg:name: Electron linux (${{ matrix.arch }})needs: [electron-plan, electron-native, electron-web]- if: needs.electron-plan.outputs.desktop == 'true'+ if: needs.electron-plan.outputs.desktop == 'true' && needs.electron-plan.outputs.linux == 'true'runs-on: ubuntu-22.04timeout-minutes: 120strategy:@@ -1554,7 +1675,7 @@ jobs:electron-linux:name: Electron linux (x64, arm64)needs: [electron-plan, electron-linux-pkg]- if: needs.electron-plan.outputs.desktop == 'true'+ if: needs.electron-plan.outputs.desktop == 'true' && needs.electron-plan.outputs.linux == 'true'runs-on: ubuntu-latesttimeout-minutes: 15steps:@@ -1572,10 +1693,13 @@ jobs:electron-publish:name: Electron publishneeds: [electron-plan, electron-mac, electron-windows, electron-linux]- # electron-mac is skipped on a stable release (macOS stays the SwiftUI app).+ # electron-mac is skipped on a stable release (macOS stays the SwiftUI app),+ # electron-windows or electron-linux in a patch release without that+ # platform; the platforms that are planned must have succeeded.if: >-- !cancelled() && needs.electron-plan.outputs.publish == 'true'- && needs.electron-windows.result == 'success' && needs.electron-linux.result == 'success'+ !cancelled() && needs.electron-plan.outputs.publish_electron == 'true'+ && (needs.electron-plan.outputs.windows != 'true' || needs.electron-windows.result == 'success')+ && (needs.electron-plan.outputs.linux != 'true' || needs.electron-linux.result == 'success')&& (needs.electron-mac.result == 'success' || needs.electron-mac.result == 'skipped')runs-on: ubuntu-latesttimeout-minutes: 30@@ -1592,11 +1716,13 @@ jobs:with:name: electron-darwinpath: electron- - uses: actions/download-artifact@v4+ - if: needs.electron-plan.outputs.windows == 'true'+ uses: actions/download-artifact@v4with:name: electron-windowspath: electron- - uses: actions/download-artifact@v4+ - if: needs.electron-plan.outputs.linux == 'true'+ uses: actions/download-artifact@v4with:name: electron-linuxpath: electron@@ -1605,6 +1731,8 @@ jobs:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}VERSION: ${{ needs.electron-plan.outputs.version }}MAC: ${{ needs.electron-mac.result }}+ WINDOWS: ${{ needs.electron-plan.outputs.windows }}+ LINUX: ${{ needs.electron-plan.outputs.linux }}run: |set -euo pipefailtag="cua-spaces-v${VERSION}"@@ -1621,7 +1749,11 @@ jobs:--base "https://github.com/$GITHUB_REPOSITORY/releases/download/$tag/" feed/*.yml# beta*.yml for a prerelease, latest*.yml for the cutover's stable one.channel=latest; [[ "$VERSION" == *-* ]] && channel=beta- wants=("$channel.yml" "$channel-linux.yml" "$channel-linux-arm64.yml")+ # Only the platforms in this release: a skipped platform has no feed+ # file here, so the published one is left untouched (CUA-2068).+ wants=()+ [ "$WINDOWS" = true ] && wants+=("$channel.yml")+ [ "$LINUX" = true ] && wants+=("$channel-linux.yml" "$channel-linux-arm64.yml")# macOS Electron only when electron-mac ran (beta, cutover).[ "$MAC" = success ] && wants+=("$channel-mac.yml")for want in "${wants[@]}"; do@@ -1634,12 +1766,16 @@ jobs:test -f "electron/$1" || { echo "::error::no electron/$1"; exit 1; }cp "electron/$1" "electron/$2"}- copy_as "Cua-Spaces-Setup-${VERSION}-x64.exe" "cua-spaces-${VERSION}-windows-x64-setup.exe"- copy_as "Cua-Spaces-Setup-${VERSION}-arm64.exe" "cua-spaces-${VERSION}-windows-arm64-setup.exe"- copy_as "Cua-Spaces-${VERSION}-x86_64.AppImage" "cua-spaces-${VERSION}-linux-x64.AppImage"- copy_as "Cua-Spaces-${VERSION}-arm64.AppImage" "cua-spaces-${VERSION}-linux-arm64.AppImage"- copy_as "cua-spaces_${VERSION}_amd64.deb" "cua-spaces-${VERSION}-linux-x64.deb"- copy_as "cua-spaces_${VERSION}_arm64.deb" "cua-spaces-${VERSION}-linux-arm64.deb"+ if [ "$WINDOWS" = true ]; then+ copy_as "Cua-Spaces-Setup-${VERSION}-x64.exe" "cua-spaces-${VERSION}-windows-x64-setup.exe"+ copy_as "Cua-Spaces-Setup-${VERSION}-arm64.exe" "cua-spaces-${VERSION}-windows-arm64-setup.exe"+ fi+ if [ "$LINUX" = true ]; then+ copy_as "Cua-Spaces-${VERSION}-x86_64.AppImage" "cua-spaces-${VERSION}-linux-x64.AppImage"+ copy_as "Cua-Spaces-${VERSION}-arm64.AppImage" "cua-spaces-${VERSION}-linux-arm64.AppImage"+ copy_as "cua-spaces_${VERSION}_amd64.deb" "cua-spaces-${VERSION}-linux-x64.deb"+ copy_as "cua-spaces_${VERSION}_arm64.deb" "cua-spaces-${VERSION}-linux-arm64.deb"+ fils -la electron feedgh release upload "$tag" electron/* --clobber --repo "$GITHUB_REPOSITORY"- uses: actions/upload-artifact@v4@@ -1725,12 +1861,14 @@ jobs:verify-release:name: Verify the signed releaseneeds: [build-macos, electron-plan, electron-mac, electron-windows, electron-publish]+ # Each platform that is in this release must have built (build-macos is+ # skipped, not failed, when a patch release has no macOS).if: >-- !cancelled() && needs.build-macos.result == 'success'- && (needs.electron-plan.outputs.desktop != 'true'- || (needs.electron-windows.result == 'success'- && (needs.electron-plan.outputs.build != 'true' || needs.electron-mac.result == 'success')))- && (needs.electron-plan.outputs.publish != 'true' || needs.electron-publish.result == 'success')+ !cancelled()+ && (needs.electron-plan.outputs.macos != 'true' || needs.build-macos.result == 'success')+ && (needs.electron-plan.outputs.windows != 'true' || needs.electron-windows.result == 'success')+ && (needs.electron-plan.outputs.build != 'true' || needs.electron-mac.result == 'success')+ && (needs.electron-plan.outputs.publish_electron != 'true' || needs.electron-publish.result == 'success')runs-on: macos-26timeout-minutes: 60defaults:@@ -1739,8 +1877,10 @@ jobs:permissions:contents: readenv:- VERSION: ${{ needs.build-macos.outputs.version }}+ VERSION: ${{ needs.electron-plan.outputs.version }}+ SWIFT: ${{ needs.electron-plan.outputs.macos }}ELECTRON: ${{ needs.electron-plan.outputs.desktop }}+ WINDOWS: ${{ needs.electron-plan.outputs.windows }}ELECTRON_MAC: ${{ needs.electron-plan.outputs.build }}SWIFT_SIGNED: ${{ needs.build-macos.outputs.signed }}ELECTRON_MAC_SIGNED: ${{ needs.electron-mac.outputs.signed }}@@ -1748,7 +1888,8 @@ jobs:APPCAST: ${{ needs.build-macos.outputs.appcast == 'true' || needs.electron-mac.outputs.appcast == 'true' }}steps:- uses: actions/checkout@v4- - uses: actions/download-artifact@v4+ - if: needs.electron-plan.outputs.macos == 'true'+ uses: actions/download-artifact@v4with:name: cua-spaces-darwin-universalpath: release@@ -1757,7 +1898,7 @@ jobs:with:name: electron-darwinpath: release- - if: needs.electron-plan.outputs.desktop == 'true'+ - if: needs.electron-plan.outputs.windows == 'true'uses: actions/download-artifact@v4with:name: electron-windows@@ -1774,7 +1915,7 @@ jobs:name: sparkle-appcastpath: release- name: Install osslsigncode (Windows Authenticode)- if: needs.electron-plan.outputs.desktop == 'true' && env.ELECTRON_WINDOWS_SIGNED == 'true'+ if: needs.electron-plan.outputs.windows == 'true' && env.ELECTRON_WINDOWS_SIGNED == 'true'run: brew install osslsigncode- name: verify-release.shrun: |@@ -1782,11 +1923,12 @@ jobs:expect=()# Production never skips verification: an unsigned artifact on the# canonical repository's release tag is a failure, not a warning.- if [ "$REQUIRE_SIGNING" = true ] && [ "$SWIFT_SIGNED" != true ]; then+ if [ "$SWIFT" != true ]; then+ echo "::notice::no macOS in this release (platform patch): the SwiftUI build is not verified"+ elif [ "$REQUIRE_SIGNING" = true ] && [ "$SWIFT_SIGNED" != true ]; thenecho "::error::trycua/cua release tag with an unsigned SwiftUI build: refusing to verify-skip"exit 1- fi- if [ "$SWIFT_SIGNED" = true ]; then+ elif [ "$SWIFT_SIGNED" = true ]; thenexpect+=(swift)elseecho "::warning::the SwiftUI build is unsigned: not verified"@@ -1800,7 +1942,8 @@ jobs:echo "::warning::the Electron macOS build is unsigned: not verified"rm -f release/Cua-Spaces-*.dmgfi- if [ "$ELECTRON_WINDOWS_SIGNED" = true ]; then expect+=(windows); else+ if [ "$WINDOWS" != true ]; then :+ elif [ "$ELECTRON_WINDOWS_SIGNED" = true ]; then expect+=(windows); elseecho "::warning::the Electron Windows build is unsigned: not verified"rm -f release/Cua-Spaces-Setup-*.exefi@@ -1829,13 +1972,14 @@ jobs:# skipped on a stable release. A release tag waits for its Electron# installers (electron-publish).# Nothing is published unless verify-release passed.+ # build-macos is skipped (not failed) in a patch release without macOS.if: >-!cancelled() && startsWith(github.ref, 'refs/tags/cua-spaces-v')- && needs.build-macos.result == 'success'+ && (needs.electron-plan.outputs.macos != 'true' || needs.build-macos.result == 'success')&& needs.verify-release.result == 'success'&& needs.staging-gate.result == 'success'&& (needs.build-linux-windows.result == 'success' || needs.build-linux-windows.result == 'skipped')- && (needs.electron-plan.outputs.publish != 'true' || needs.electron-publish.result == 'success')+ && (needs.electron-plan.outputs.publish_electron != 'true' || needs.electron-publish.result == 'success')runs-on: ubuntu-latestpermissions:contents: write@@ -1850,7 +1994,7 @@ jobs:- name: Resolve versionid: versionenv:- VERSION: ${{ needs.build-macos.outputs.version }}+ VERSION: ${{ needs.electron-plan.outputs.version }}run: |echo "version=$VERSION" >> "$GITHUB_OUTPUT"echo "tag=cua-spaces-v$VERSION" >> "$GITHUB_OUTPUT"@@ -1865,6 +2009,7 @@ jobs:VERSION: ${{ steps.version.outputs.version }}TAG: ${{ steps.version.outputs.tag }}TAURI: ${{ needs.build-linux-windows.result }}+ PARTIAL: ${{ needs.electron-plan.outputs.partial }}run: |set -euo pipefailBASE="https://github.com/$GITHUB_REPOSITORY/releases/download/$TAG"@@ -1886,12 +2031,22 @@ jobs:mv "$RUNNER_TEMP/checksums.txt" assets/checksums.txtgh release download cua-install-latest --pattern release-artifacts.json \--dir previous --repo "$GITHUB_REPOSITORY" 2>/dev/null || true+ # A patch release without some platforms (CUA-2068) keeps those+ # platforms' artifacts from the previous manifest, each with its own+ # version, so install.sh / install.ps1 install the newest build per+ # platform. A full release replaces them all, as before.+ carry=()+ if [ "$PARTIAL" = true ]; then+ test -f previous/release-artifacts.json \+ || { echo "::error::a platform patch needs the previous cua-install-latest manifest to carry the other platforms forward"; exit 1; }+ carry=(--carry-forward-platforms)+ fipython3 scripts/install/release_manifest.py --component app --version "$VERSION" \--dir assets --base-url "$BASE" \- --repo "$GITHUB_REPOSITORY" --merge previous/release-artifacts.json --out assets/release-artifacts.json+ --repo "$GITHUB_REPOSITORY" --merge previous/release-artifacts.json "${carry[@]}" --out assets/release-artifacts.json# Every published artifact is listed, with its checksum (CUA-1507).python3 scripts/install/check_release_manifest.py --dir assets --component app \- --version "$VERSION" --base-url "$BASE"+ --version "$VERSION" --base-url "$BASE" ${carry:+--allow-carried-forward}# The Tauri updater feed (latest.json) only when the Tauri app# (build-linux-windows) ran and built its updater artifacts. The# Electron app for Windows and Linux updates from latest*.yml.@@ -1909,7 +2064,7 @@ jobs:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}TAG: ${{ steps.version.outputs.tag }}VERSION: ${{ steps.version.outputs.version }}- PRERELEASE: ${{ needs.build-macos.outputs.prerelease }}+ PRERELEASE: ${{ needs.electron-plan.outputs.prerelease }}run: |set -euo pipefailflags=(--draft=false)@@ -1932,6 +2087,27 @@ jobs:flags+=(--title "Cua Spaces v$VERSION ($label)" --notes-file notes.md)figh release edit "$TAG" "${flags[@]}" --repo "$GITHUB_REPOSITORY"+ # Say which platforms a patch release contains (CUA-2068). A full release+ # keeps its notes as they are.+ - name: Name the platforms in the release notes+ if: needs.electron-plan.outputs.partial == 'true'+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ TAG: ${{ steps.version.outputs.tag }}+ PLATFORMS: ${{ needs.electron-plan.outputs.platforms }}+ run: |+ set -euo pipefail+ gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json body --jq .body > body.md+ # Idempotent on a re-run: drop an earlier block first.+ sed -i '/<!-- cua-platforms -->/,/<!-- \/cua-platforms -->/d' body.md+ {+ cat body.md+ echo+ echo '<!-- cua-platforms -->'+ python3 .github/scripts/spaces_platforms.py notes --platforms "$PLATFORMS" --manifest assets/release-artifacts.json+ echo '<!-- /cua-platforms -->'+ } > notes-with-platforms.md+ gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --notes-file notes-with-platforms.md# The Electron feed, once the release it names is published: beta*.yml# for a prerelease (stable apps never read it, so a trycua/cua# prerelease updates it too, like the Sparkle beta items below),@@ -1946,8 +2122,8 @@ jobs:- name: Upload the Electron feed to cua-spaces-latestif: >-needs.electron-publish.result == 'success'- && (contains(needs.build-macos.outputs.version, '-')- || needs.build-macos.outputs.prerelease != 'true' || github.repository != 'trycua/cua')+ && (contains(needs.electron-plan.outputs.version, '-')+ || needs.electron-plan.outputs.prerelease != 'true' || github.repository != 'trycua/cua')env:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}run: |@@ -1989,7 +2165,7 @@ jobs:# trycua/cua stays off the rolling feeds; on any other repository the# feeds are that repository's own, so they follow every release.- name: Update the rolling feeds (cua-spaces-latest, cua-install-latest)- if: needs.build-macos.outputs.prerelease != 'true' || github.repository != 'trycua/cua'+ if: needs.electron-plan.outputs.prerelease != 'true' || github.repository != 'trycua/cua'env:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}run: |diff --git a/scripts/install/README.md b/scripts/install/README.mdindex b5302d9169..15394e1401 100644--- a/scripts/install/README.md+++ b/scripts/install/README.md@@ -54,6 +54,10 @@ For cua-driver, `--prefix DIR` becomes `--bin-dir DIR/bin`, `--require-signaturePass install.sh options through the pipe with `sh -s --`, for example `curl -fsSL https://cua.ai/install.sh | sh -s -- --cli-only --yes`. `--only` and `--select` cannot be combined, nor can `--cli-only` with other items. Set `CUA_INSTALL_NONINTERACTIVE=1` to never prompt.+## Partial releases++A Cua Spaces patch can ship one platform only (a macOS fix does not rebuild Windows or Linux). The release manifest (`release-artifacts.json`, also the rolling `cua-install-latest` copy) then holds a different version per platform: the release builds its own platforms and `release_manifest.py --carry-forward-platforms` keeps the earlier entries for the others, each with its own `version` and download URL. `install.sh` and `install.ps1` read only the entries for their own platform, so each installs the newest build that exists for it. `tests/test_mixed_versions.py` and the `mixed versions` Pester tests cover this.+## TelemetryBoth installers send three anonymous events about their own run (`cua_installer_step`: `installer_started`, then `installer_completed` or `installer_failed` with the stage and a fixed reason word), and print a two-line notice before the first one. They follow the switches every Cua program uses: `DO_NOT_TRACK=1`, `CUA_TELEMETRY=0`, `[telemetry] enabled = "off"` in `$CUA_HOME/config.toml`, and off in CI unless `CUA_TELEMETRY=1`. `--dry-run` sends nothing. They create or reuse `$CUA_HOME/telemetry/install_id`, the anonymous id the CLI and app send with, and never send a name, path, URL or error message. The tests set `CUA_TELEMETRY_FORBID_NETWORK=1`, which allows only a loopback `CUA_TELEMETRY_ENDPOINT`. See [Telemetry and privacy](https://cua.ai/docs/cua-sdk/concepts/telemetry).diff --git a/scripts/install/check_release_manifest.py b/scripts/install/check_release_manifest.pyindex 1d63dbfbc7..ca638068a3 100644--- a/scripts/install/check_release_manifest.py+++ b/scripts/install/check_release_manifest.py@@ -14,7 +14,10 @@ It fails unless:recognises: the SwiftUI, Electron, Tauri and CLI artifacts) is listed inrelease-artifacts.json under that component and version, with the file'ssha256 and size and, with --base-url, its download URL; and every listed- artifact of that component names an asset that is here.+ artifact of that component names an asset that is here. With+ --allow-carried-forward (a partial release), an entry of another version is+ a platform's earlier build: it must carry a url and sha256 but need not name+ an asset of this release."""from __future__ import annotations@@ -30,7 +33,7 @@ from release_manifest import classify, sha256 # noqa: E402META = {"checksums.txt", "release-artifacts.json", "latest.json"}-def check(directory: Path, component: str, version: str, base_url: str | None) -> list[str]:+def check(directory: Path, component: str, version: str, base_url: str | None, carried: bool = False) -> list[str]:errors: list[str] = []assets = {p.name: p@@ -91,7 +94,14 @@ def check(directory: Path, component: str, version: str, base_url: str | None) -errors.append(f"{where} version {row.get('version')!r}, want {version!r}")if base_url and row.get("url") != f"{base_url.rstrip('/')}/{name}":errors.append(f"{where} url {row.get('url')} is not {base_url.rstrip('/')}/{name}")- for name in by_name:+ for name, rows in by_name.items():+ # A partial release keeps other platforms' entries from their own+ # (older) release; they name assets of that release, not this one.+ if carried and all(row.get("version") != version for row in rows):+ for row in rows:+ if not row.get("url") or not row.get("sha256"):+ errors.append(f"release-artifacts.json: carried-forward {name} ({row.get('platform')}) lacks a url or sha256")+ continueif name not in assets:errors.append(f"release-artifacts.json lists {name}, which is not on the release")return errors@@ -103,8 +113,10 @@ def main(argv: list[str] | None = None) -> int:parser.add_argument("--component", choices=("cli", "app"), required=True)parser.add_argument("--version", required=True)parser.add_argument("--base-url")+ parser.add_argument("--allow-carried-forward", action="store_true",+ help="partial release: entries of another version are other platforms' earlier builds")args = parser.parse_args(argv)- errors = check(Path(args.dir), args.component, args.version, args.base_url)+ errors = check(Path(args.dir), args.component, args.version, args.base_url, args.allow_carried_forward)for error in errors:print(f"FAIL {error}")if errors:diff --git a/scripts/install/install.ps1 b/scripts/install/install.ps1index 432f2caa65..52381a177c 100644--- a/scripts/install/install.ps1+++ b/scripts/install/install.ps1@@ -824,7 +824,9 @@ function Invoke-CuaInstallSteps($sel) {$manifest = Get-Content -Raw -LiteralPath $manifestFile | ConvertFrom-Jsonif ($manifest.schema -ne 1) { Stop-Install "unsupported release manifest at $manifestUrl" }Write-Info "platform $platform, manifest $manifestUrl"- $script:TelVersion = "$(@($manifest.artifacts | Where-Object { $_.component -eq 'cli' } | Select-Object -First 1).version)"+ # A per-platform release may carry no cli artifact; StrictMode rejects .version on $null.+ $cliArtifact = $manifest.artifacts | Where-Object { $_.component -eq 'cli' } | Select-Object -First 1+ $script:TelVersion = if ($cliArtifact) { "$($cliArtifact.version)" } else { '' }}$script:TelStage = 'cli'if ($sel.cli) { $cua = Install-Cli $manifest $manifestUrl $platform $tmp }diff --git a/scripts/install/release_manifest.py b/scripts/install/release_manifest.pyindex 22bc63d75e..b4a5b473be 100644--- a/scripts/install/release_manifest.py+++ b/scripts/install/release_manifest.py@@ -162,7 +162,21 @@ def build(args: argparse.Namespace) -> dict:if previous.get("schema") != SCHEMA:raise SystemExit(f"{args.merge}: unsupported schema {previous.get('schema')!r}")ours = scan(args.component, args.version, Path(args.dir), args.base_url)- kept = [a for a in previous.get("artifacts", []) if a.get("component") != args.component]+ if args.carry_forward_platforms:+ # A partial release (CUA-2068): platforms this release did not build+ # keep the artifacts of the build that is current for them, each with+ # its own version, so the installers pick the newest build per platform.+ built = {a["platform"] for a in ours}+ kept = [a for a in previous.get("artifacts", []) if a.get("component") != args.component or a.get("platform") not in built]+ carried = {a["platform"] for a in kept if a.get("component") == args.component}+ missing = [p for p in PLATFORMS if p not in built and p not in carried]+ if missing:+ raise SystemExit(+ f"--carry-forward-platforms: no previous {args.component} artifact for {', '.join(missing)}; "+ "a platform with nothing to carry forward must be built"+ )+ else:+ kept = [a for a in previous.get("artifacts", []) if a.get("component") != args.component]versions = dict(previous.get("versions", {}))versions[args.component] = args.versionartifacts = sorted(kept + ours, key=lambda a: (a["component"], a["platform"], a["kind"]))@@ -177,6 +191,12 @@ def main(argv: list[str] | None = None) -> int:parser.add_argument("--base-url", help="download URL prefix (default: names relative to the manifest)")parser.add_argument("--merge", help="existing manifest; its other components are kept")parser.add_argument("--repo", default="trycua/cua")+ parser.add_argument(+ "--carry-forward-platforms",+ action="store_true",+ help="partial release: keep the --merge file's artifacts for platforms this release has none for "+ "(default: replace every artifact of the component)",+ )parser.add_argument("--out", help="output path (default stdout)")args = parser.parse_args(argv)text = render(build(args))diff --git a/scripts/install/tests/install.Tests.ps1 b/scripts/install/tests/install.Tests.ps1index 0566b4c3c4..158f0ad929 100644--- a/scripts/install/tests/install.Tests.ps1+++ b/scripts/install/tests/install.Tests.ps1@@ -423,6 +423,48 @@ Describe 'install.ps1' {}}+# Partial releases (CUA-2068): cua-install-latest can hold one version per+# platform. Built with the real release_manifest.py, as cd-cua-spaces.yml does:+# 1.2.3 ships every platform, 1.2.4 only macOS, then 1.2.5 only Windows.+Describe 'mixed versions' {+ BeforeAll {+ $mix = Join-Path $env:CUA_TEST_ROOT 'mixed'+ function Build-Release([string]$Version, [string[]]$Names, [string]$Merge) {+ $dir = Join-Path $mix "v$Version"+ New-Item -ItemType Directory -Force -Path $dir | Out-Null+ foreach ($n in $Names) { Set-Content -LiteralPath (Join-Path $dir ($n -creplace 'VER', $Version)) -Value $n }+ $out = Join-Path $mix "manifest-$Version.json"+ $toolArgs = @('--component', 'app', '--version', $Version, '--dir', $dir,+ '--base-url', "https://example.invalid/cua-spaces-v$Version", '--out', $out)+ if ($Merge) { $toolArgs += @('--merge', $Merge, '--carry-forward-platforms') }+ & $Python.Source $Tool @toolArgs+ return $out+ }+ $m123 = Build-Release '1.2.3' @('cua-spaces-VER-darwin-universal.dmg', 'cua-spaces-VER-windows-x64-setup.exe', 'cua-spaces-VER-windows-arm64-setup.exe', 'cua-spaces-VER-linux-x64.AppImage', 'cua-spaces-VER-linux-arm64.AppImage') ''+ $m124 = Build-Release '1.2.4' @('cua-spaces-VER-darwin-universal.dmg') $m123+ $m125 = Build-Release '1.2.5' @('cua-spaces-VER-windows-x64-setup.exe', 'cua-spaces-VER-windows-arm64-setup.exe') $m124+ $url124 = ConvertTo-FileUrl $m124+ $url125 = ConvertTo-FileUrl $m125+ }++ It 'a macOS-only release leaves Windows on its own build' {+ foreach ($arch in 'AMD64', 'ARM64') {+ $out = Invoke-Installer @{ DryRun = $true; Yes = $true; AppOnly = $true } @{ CUA_INSTALL_MANIFEST_URL = $url124; CUA_INSTALL_ARCH = $arch }+ $out | Should -Match 'cua-spaces-v1\.2\.3/cua-spaces-1\.2\.3-windows-'+ $out | Should -Not -Match '1\.2\.4'+ }+ }++ It 'a later Windows-only release installs the newest Windows build' {+ $arch = @{ AMD64 = 'x64'; ARM64 = 'arm64' }+ foreach ($a in 'AMD64', 'ARM64') {+ $out = Invoke-Installer @{ DryRun = $true; Yes = $true; AppOnly = $true } @{ CUA_INSTALL_MANIFEST_URL = $url125; CUA_INSTALL_ARCH = $a }+ $out | Should -Match "cua-spaces-v1\.2\.5/cua-spaces-1\.2\.5-windows-$($arch[$a])-setup\.exe"+ $out | Should -Not -Match '1\.2\.3'+ }+ }+}+Describe 'install telemetry' {BeforeAll {$env:CUA_INSTALL_NO_RUN = '1'diff --git a/scripts/install/tests/test_mixed_versions.py b/scripts/install/tests/test_mixed_versions.pynew file mode 100644index 0000000000..7b2c549e47--- /dev/null+++ b/scripts/install/tests/test_mixed_versions.py@@ -0,0 +1,171 @@+"""Partial (per-platform) releases: install.sh and install.ps1 take the newest+build that exists for their own platform (CUA-2068; python3 -m unittest+discover -s scripts/install/tests). install.ps1 runs only on Windows: its half+is in install.Tests.ps1 ('mixed versions'), built the same way.++The manifest is built the way cd-cua-spaces.yml builds it: release 1.2.3 ships+every platform, 1.2.4 only macOS and 1.2.5 only Linux, each merged into the+previous manifest with --carry-forward-platforms. The result holds three+versions at once. A loopback server plays GitHub's release downloads, one+directory per release tag.+"""++import http.server+import json+import os+import shutil+import subprocess+import tempfile+import threading+import unittest+from pathlib import Path++HERE = Path(__file__).resolve().parent+SH = HERE.parent / "install.sh"+PS1 = HERE.parent / "install.ps1"+TOOL = HERE.parent / "release_manifest.py"+CHECK = HERE.parent / "check_release_manifest.py"++FILES = {+ "1.2.3": [+ "cua-spaces-{v}-darwin-universal.dmg",+ "cua-spaces-{v}-linux-x64.AppImage",+ "cua-spaces-{v}-linux-arm64.AppImage",+ "cua-spaces-{v}-linux-x64.deb",+ "cua-spaces-{v}-linux-arm64.deb",+ "cua-spaces-{v}-windows-x64-setup.exe",+ "cua-spaces-{v}-windows-arm64-setup.exe",+ ],+ "1.2.4": ["cua-spaces-{v}-darwin-universal.dmg"],+ "1.2.5": [+ "cua-spaces-{v}-linux-x64.AppImage",+ "cua-spaces-{v}-linux-arm64.AppImage",+ "cua-spaces-{v}-linux-x64.deb",+ "cua-spaces-{v}-linux-arm64.deb",+ ],+}+++def tool(*args):+ return subprocess.run(["python3", str(TOOL), *args], check=True, capture_output=True, text=True)+++class MixedVersions(unittest.TestCase):+ @classmethod+ def setUpClass(cls):+ cls.tmp = tempfile.TemporaryDirectory()+ root = Path(cls.tmp.name)+ cls.release = root / "release"++ class Quiet(http.server.SimpleHTTPRequestHandler):+ def log_message(self, *args):+ pass++ handler = lambda *a, **k: Quiet(*a, directory=str(cls.release), **k) # noqa: E731+ cls.server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), handler)+ threading.Thread(target=cls.server.serve_forever, daemon=True).start()+ cls.base = f"http://127.0.0.1:{cls.server.server_address[1]}"+ previous = None+ cls.manifests = {}+ for version, names in FILES.items():+ tag = cls.release / f"cua-spaces-v{version}"+ tag.mkdir(parents=True)+ for name in names:+ body = f"#!/bin/sh\necho cua-spaces {version}\n" if name.endswith(".AppImage") else f"{name}\n"+ (tag / name.format(v=version)).write_text(body)+ out = root / f"manifest-{version}.json"+ args = ["--component", "app", "--version", version, "--dir", str(tag),+ "--base-url", f"{cls.base}/cua-spaces-v{version}", "--out", str(out)]+ if previous:+ args += ["--merge", str(previous), "--carry-forward-platforms"]+ tool(*args)+ cls.manifests[version] = out+ previous = out+ # What cua-install-latest holds after all three releases.+ latest = cls.release / "cua-install-latest"+ latest.mkdir()+ shutil.copy(previous, latest / "release-artifacts.json")+ cls.manifest_url = f"{cls.base}/cua-install-latest/release-artifacts.json"+ cls.manifest = json.loads(previous.read_text())++ @classmethod+ def tearDownClass(cls):+ cls.server.shutdown()+ cls.tmp.cleanup()++ def versions(self, manifest=None):+ found = {}+ for a in (manifest or self.manifest)["artifacts"]:+ found.setdefault(a["platform"], set()).add(a["version"])+ return found++ def test_manifest_holds_the_newest_build_per_platform(self):+ self.assertEqual(+ self.versions(),+ {+ "darwin-arm64": {"1.2.4"}, "darwin-x64": {"1.2.4"},+ "linux-arm64": {"1.2.5"}, "linux-x64": {"1.2.5"},+ "windows-arm64": {"1.2.3"}, "windows-x64": {"1.2.3"},+ },+ )+ self.assertEqual(self.manifest["versions"]["app"], "1.2.5")++ def test_carry_forward_is_opt_in(self):+ # Without the flag, the component's earlier artifacts are replaced, as before.+ out = Path(self.tmp.name) / "replaced.json"+ tool("--component", "app", "--version", "1.2.4", "--dir", str(self.release / "cua-spaces-v1.2.4"),+ "--merge", str(self.manifests["1.2.3"]), "--out", str(out))+ self.assertEqual(set(self.versions(json.loads(out.read_text()))), {"darwin-arm64", "darwin-x64"})++ def test_a_platform_with_nothing_to_carry_forward_is_an_error(self):+ p = subprocess.run(+ ["python3", str(TOOL), "--component", "app", "--version", "1.2.4",+ "--dir", str(self.release / "cua-spaces-v1.2.4"), "--carry-forward-platforms"],+ capture_output=True, text=True,+ )+ self.assertNotEqual(p.returncode, 0)+ self.assertIn("no previous app artifact", p.stderr)++ def test_checker_accepts_a_partial_release_only_when_allowed(self):+ tag = self.release / "cua-spaces-v1.2.4"+ work = Path(self.tmp.name) / "check"+ shutil.copytree(tag, work)+ shutil.copy(self.manifests["1.2.4"], work / "release-artifacts.json")+ import hashlib+ (work / "checksums.txt").write_text("".join(+ f"{hashlib.sha256(p.read_bytes()).hexdigest()} {p.name}\n"+ for p in sorted(work.iterdir()) if p.name not in ("release-artifacts.json", "checksums.txt")))+ base = f"{self.base}/cua-spaces-v1.2.4"+ args = ["python3", str(CHECK), "--dir", str(work), "--component", "app", "--version", "1.2.4", "--base-url", base]+ self.assertNotEqual(subprocess.run(args, capture_output=True).returncode, 0)+ self.assertEqual(subprocess.run([*args, "--allow-carried-forward"], capture_output=True, text=True).returncode, 0)++ def sh(self, os_name, arch, prefix, *extra):+ env = {+ "PATH": os.environ["PATH"], "HOME": str(prefix), "CUA_HOME": str(prefix / ".cua"),+ "CUA_INSTALL_OS": os_name, "CUA_INSTALL_ARCH": arch,+ "CUA_INSTALL_MANIFEST_URL": self.manifest_url, "CUA_TELEMETRY_FORBID_NETWORK": "1",+ }+ return subprocess.run(+ ["sh", str(SH), "--yes", "--no-onboarding", "--app-only", "--prefix", str(prefix / "p"), *extra],+ env=env, stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=120,+ )++ def test_install_sh_installs_the_newest_linux_build(self):+ for arch, label in (("x86_64", "linux-x64"), ("aarch64", "linux-arm64")):+ prefix = Path(tempfile.mkdtemp(dir=self.tmp.name))+ p = self.sh("linux", arch, prefix)+ self.assertEqual(p.returncode, 0, p.stdout + p.stderr)+ ran = subprocess.run([str(prefix / "p/bin/cua-spaces")], capture_output=True, text=True)+ self.assertEqual(ran.stdout.strip(), "cua-spaces 1.2.5", label)++ def test_install_sh_plans_the_newest_macos_build(self):+ prefix = Path(tempfile.mkdtemp(dir=self.tmp.name))+ p = self.sh("Darwin", "arm64", prefix, "--dry-run")+ self.assertEqual(p.returncode, 0, p.stdout + p.stderr)+ self.assertIn("cua-spaces-v1.2.4/cua-spaces-1.2.4-darwin-universal.dmg", p.stdout)+ self.assertNotIn("1.2.3", p.stdout)+++if __name__ == "__main__":+ unittest.main()