Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-driver): advance installers only after release publication

Francesco Bonaccidad42d1932d9
diff --git a/.github/release-state/cua-driver-rs-published-version b/.github/release-state/cua-driver-rs-published-version
new file mode 100644
index 0000000000..a803cc227f
--- /dev/null
+++ b/.github/release-state/cua-driver-rs-published-version
@@ -0,0 +1 @@
+0.14.0
diff --git a/.github/scripts/tests/test_cua_driver_release_wiring.py b/.github/scripts/tests/test_cua_driver_release_wiring.py
index 25f02de32e..02183ebd38 100644
--- a/.github/scripts/tests/test_cua_driver_release_wiring.py
+++ b/.github/scripts/tests/test_cua_driver_release_wiring.py
@@ -220,7 +220,7 @@ class TestCuaDriverReleaseWiring(unittest.TestCase):
relative_path,
)
- def test_release_please_keeps_driver_version_sources_synced(self) -> None:
+ def test_release_please_keeps_release_version_sources_synced(self) -> None:
config = self.read("release-please-config.json")
self.assertIn('"path": "rust/Cargo.toml"', config)
@@ -230,10 +230,62 @@ class TestCuaDriverReleaseWiring(unittest.TestCase):
self.assertEqual(
config.count('"path": "typescript/package-lock.json"'), 2
)
- self.assertIn('"path": "scripts/_install-rust.sh"', config)
- self.assertIn('"path": "scripts/install.ps1"', config)
+ self.assertNotIn('"path": "scripts/_install-rust.sh"', config)
+ self.assertNotIn('"path": "scripts/install.ps1"', config)
self.assertIn('"path": "rust/Skills/cua-driver/SKILL.md"', config)
+ def test_driver_installer_version_advances_only_after_publication(self) -> None:
+ workflow = self.read(".github/workflows/cd-rust-cua-driver.yml")
+
+ release_job = workflow.index(" release:")
+ control_checkout = workflow.index(
+ "- name: Check out release control tooling", release_job
+ )
+ stamp = workflow.index(
+ "python3 release-control/.github/scripts/"
+ "update_cua_driver_installer_version.py",
+ control_checkout,
+ )
+ staged_shell = workflow.index(
+ "--shell-path release-upload/_install-rust.sh", stamp
+ )
+ staged_powershell = workflow.index(
+ "--powershell-path release-upload/install.ps1", stamp
+ )
+ publish = workflow.index(
+ "- name: Publish the verified Release Please draft", staged_powershell
+ )
+ verify_public = workflow.index(
+ "- name: Verify the release and every staged asset are public", publish
+ )
+ app_token = workflow.index(
+ "- name: Generate post-publication GitHub App token", verify_public
+ )
+ advance = workflow.index(
+ "- name: Advance public installer version on main", app_token
+ )
+
+ self.assertLess(release_job, control_checkout)
+ self.assertLess(control_checkout, stamp)
+ self.assertLess(stamp, staged_shell)
+ self.assertLess(staged_shell, staged_powershell)
+ self.assertLess(staged_powershell, publish)
+ self.assertLess(publish, verify_public)
+ self.assertLess(verify_public, app_token)
+ self.assertLess(app_token, advance)
+ self.assertIn("ref: ${{ github.workflow_sha }}", workflow)
+ self.assertIn("path: release-control", workflow)
+ self.assertIn("select(.draft == false and .published_at != null)", workflow)
+ self.assertIn("missing-release-assets.txt", workflow)
+ self.assertIn("--allow-newer", workflow)
+ self.assertIn(
+ "--state-path "
+ '"$UPDATE_ROOT/.github/release-state/cua-driver-rs-published-version"',
+ workflow,
+ )
+ self.assertIn("-F force=false", workflow)
+ self.assertIn("[skip ci]", workflow)
+
def test_release_installers_preserve_legacy_telemetry_state_before_cleanup(self) -> None:
installer = self.read("libs/cua-driver/scripts/_install-rust.sh")
cleanup = installer.index('rm -rf "$LEGACY_HOME_DIR"')
diff --git a/.github/scripts/tests/test_update_cua_driver_installer_version.py b/.github/scripts/tests/test_update_cua_driver_installer_version.py
new file mode 100644
index 0000000000..47d7a39d1a
--- /dev/null
+++ b/.github/scripts/tests/test_update_cua_driver_installer_version.py
@@ -0,0 +1,110 @@
+from pathlib import Path
+
+import pytest
+
+from update_cua_driver_installer_version import (
+ InstallerVersionError,
+ POWERSHELL_VERSION,
+ SHELL_VERSION,
+ read_version,
+ update_installer_versions,
+)
+
+
+REPO_ROOT = Path(__file__).resolve().parents[3]
+
+
+def copy_installers(tmp_path: Path) -> tuple[Path, Path, Path]:
+ source = REPO_ROOT / "libs/cua-driver/scripts"
+ shell = tmp_path / "_install-rust.sh"
+ powershell = tmp_path / "install.ps1"
+ shell.write_bytes((source / shell.name).read_bytes())
+ powershell.write_bytes((source / powershell.name).read_bytes())
+ state = tmp_path / "published-version"
+ state.write_bytes(
+ (
+ REPO_ROOT
+ / ".github/release-state/cua-driver-rs-published-version"
+ ).read_bytes()
+ )
+ return shell, powershell, state
+
+
+def test_updates_both_installer_sentinels_and_is_idempotent(tmp_path: Path) -> None:
+ shell, powershell, state = copy_installers(tmp_path)
+
+ changed = update_installer_versions(
+ shell, powershell, "999.998.997", state_path=state
+ )
+
+ assert changed == (shell, powershell, state)
+ assert read_version(shell, SHELL_VERSION) == "999.998.997"
+ assert read_version(powershell, POWERSHELL_VERSION) == "999.998.997"
+ assert state.read_text() == "999.998.997\n"
+ assert update_installer_versions(
+ shell, powershell, "999.998.997", state_path=state
+ ) == ()
+
+
+def test_refuses_to_downgrade_baked_installers(tmp_path: Path) -> None:
+ shell, powershell, state = copy_installers(tmp_path)
+ update_installer_versions(
+ shell, powershell, "999.998.997", state_path=state
+ )
+
+ with pytest.raises(InstallerVersionError, match="refusing to move"):
+ update_installer_versions(
+ shell, powershell, "999.998.996", state_path=state
+ )
+
+ assert update_installer_versions(
+ shell,
+ powershell,
+ "999.998.996",
+ state_path=state,
+ allow_newer=True,
+ ) == ()
+ assert read_version(shell, SHELL_VERSION) == "999.998.997"
+ assert read_version(powershell, POWERSHELL_VERSION) == "999.998.997"
+
+
[email protected]("version", ["v1.2.3", "1.2", "1.2.3-rc.1", "latest"])
+def test_rejects_non_stable_versions(tmp_path: Path, version: str) -> None:
+ shell, powershell, _ = copy_installers(tmp_path)
+
+ with pytest.raises(InstallerVersionError, match="exact stable"):
+ update_installer_versions(shell, powershell, version)
+
+
+def test_refuses_mismatched_installer_state(tmp_path: Path) -> None:
+ shell, powershell, state = copy_installers(tmp_path)
+ shell.write_text(
+ SHELL_VERSION.sub(r"\g<1>1.2.3\g<3>", shell.read_text(), count=1)
+ )
+
+ with pytest.raises(InstallerVersionError, match="versions disagree"):
+ update_installer_versions(
+ shell, powershell, "999.998.997", state_path=state
+ )
+
+
+def test_accepts_legacy_release_please_sentinels_for_tag_recovery(
+ tmp_path: Path,
+) -> None:
+ shell, powershell, _ = copy_installers(tmp_path)
+ shell.write_text(
+ shell.read_text().replace(
+ "# published-installer-version", "# x-release-please-version"
+ )
+ )
+ powershell.write_text(
+ powershell.read_text().replace(
+ "# published-installer-version", "# x-release-please-version"
+ )
+ )
+
+ changed = update_installer_versions(shell, powershell, "999.998.997")
+
+ assert changed == (shell, powershell)
+ assert "# x-release-please-version" in shell.read_text()
+ assert "# x-release-please-version" in powershell.read_text()
diff --git a/.github/scripts/tests/test_validate_release_versions.py b/.github/scripts/tests/test_validate_release_versions.py
index a35dc8a1da..0a8ab5a44d 100644
--- a/.github/scripts/tests/test_validate_release_versions.py
+++ b/.github/scripts/tests/test_validate_release_versions.py
@@ -1,4 +1,5 @@
from pathlib import Path
+import re
import shutil
import pytest
@@ -11,6 +12,9 @@ REPO_ROOT = Path(__file__).resolve().parents[3]
def copy_release_sources(destination: Path) -> None:
shutil.copy(REPO_ROOT / ".release-please-manifest.json", destination)
+ release_state = ".github/release-state/cua-driver-rs-published-version"
+ (destination / release_state).parent.mkdir(parents=True, exist_ok=True)
+ shutil.copy(REPO_ROOT / release_state, destination / release_state)
for relative in ("libs/cua-driver", "libs/lume"):
source = REPO_ROOT / relative
target = destination / relative
@@ -32,3 +36,61 @@ def test_version_drift_fails_with_the_source_name(tmp_path: Path):
path.write_text(path.read_text().replace(f'"{current}"', '"9.9.9"'))
with pytest.raises(VersionError, match="src/Main.swift=9.9.9"):
validate(tmp_path, "lume")
+
+
+def set_driver_installer_versions(
+ root: Path, *, shell_version: str, powershell_version: str
+) -> None:
+ state = root / ".github/release-state/cua-driver-rs-published-version"
+ state.write_text(f"{shell_version}\n")
+ shell = root / "libs/cua-driver/scripts/_install-rust.sh"
+ shell_source = shell.read_text()
+ shell.write_text(
+ re.sub(
+ r'^CUA_DRIVER_RS_BAKED_VERSION="[^"]+"',
+ f'CUA_DRIVER_RS_BAKED_VERSION="{shell_version}"',
+ shell_source,
+ count=1,
+ flags=re.MULTILINE,
+ )
+ )
+ powershell = root / "libs/cua-driver/scripts/install.ps1"
+ powershell_source = powershell.read_text()
+ powershell.write_text(
+ re.sub(
+ r'^\$Script:CuaDriverRsBakedVersion\s*=\s*"[^"]+"',
+ f'$Script:CuaDriverRsBakedVersion = "{powershell_version}"',
+ powershell_source,
+ count=1,
+ flags=re.MULTILINE,
+ )
+ )
+
+
+def test_driver_validation_allows_installer_to_lag_until_publication(tmp_path: Path):
+ copy_release_sources(tmp_path)
+ set_driver_installer_versions(
+ tmp_path, shell_version="0.0.0", powershell_version="0.0.0"
+ )
+
+ validate(tmp_path, "driver")
+
+
+def test_driver_validation_rejects_disagreeing_installer_versions(tmp_path: Path):
+ copy_release_sources(tmp_path)
+ set_driver_installer_versions(
+ tmp_path, shell_version="0.0.0", powershell_version="0.0.1"
+ )
+
+ with pytest.raises(VersionError, match="baked installers"):
+ validate(tmp_path, "driver")
+
+
+def test_driver_validation_rejects_installer_version_ahead_of_source(tmp_path: Path):
+ copy_release_sources(tmp_path)
+ set_driver_installer_versions(
+ tmp_path, shell_version="9.9.9", powershell_version="9.9.9"
+ )
+
+ with pytest.raises(VersionError, match="ahead of source release"):
+ validate(tmp_path, "driver")
diff --git a/.github/scripts/update_cua_driver_installer_version.py b/.github/scripts/update_cua_driver_installer_version.py
new file mode 100644
index 0000000000..94ba4804f2
--- /dev/null
+++ b/.github/scripts/update_cua_driver_installer_version.py
@@ -0,0 +1,149 @@
+#!/usr/bin/env python3
+"""Advance the baked Cua Driver installer version after publication."""
+
+from __future__ import annotations
+
+import argparse
+from pathlib import Path
+import re
+from typing import Sequence
+
+
+class InstallerVersionError(RuntimeError):
+ """Raised when installer version state cannot be updated safely."""
+
+
+STABLE_VERSION = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+$")
+SHELL_VERSION = re.compile(
+ r'^(CUA_DRIVER_RS_BAKED_VERSION=")([^"]+)(" # (?:published-installer-version|x-release-please-version))$',
+ re.MULTILINE,
+)
+POWERSHELL_VERSION = re.compile(
+ r'^(\$Script:CuaDriverRsBakedVersion\s*=\s*")([^"]+)(" # (?:published-installer-version|x-release-please-version))$',
+ re.MULTILINE,
+)
+
+
+def version_tuple(version: str) -> tuple[int, int, int]:
+ if not STABLE_VERSION.fullmatch(version):
+ raise InstallerVersionError(
+ f"installer version must be an exact stable x.y.z value: {version!r}"
+ )
+ major, minor, patch = version.split(".")
+ return int(major), int(minor), int(patch)
+
+
+def read_version(path: Path, pattern: re.Pattern[str]) -> str:
+ matches = list(pattern.finditer(path.read_text(encoding="utf-8-sig")))
+ if len(matches) != 1:
+ raise InstallerVersionError(
+ f"expected exactly one baked-version sentinel in {path}, found {len(matches)}"
+ )
+ version = matches[0].group(2)
+ version_tuple(version)
+ return version
+
+
+def _replace_version(path: Path, pattern: re.Pattern[str], version: str) -> bool:
+ source = path.read_text(encoding="utf-8-sig")
+ matches = list(pattern.finditer(source))
+ if len(matches) != 1:
+ raise InstallerVersionError(
+ f"expected exactly one baked-version sentinel in {path}, found {len(matches)}"
+ )
+ updated = pattern.sub(rf"\g<1>{version}\g<3>", source, count=1)
+ if updated == source:
+ return False
+ path.write_text(updated, encoding="utf-8")
+ return True
+
+
+def _replace_state_version(path: Path, version: str) -> bool:
+ current = path.read_text(encoding="utf-8").strip()
+ version_tuple(current)
+ if current == version:
+ return False
+ path.write_text(f"{version}\n", encoding="utf-8")
+ return True
+
+
+def update_installer_versions(
+ shell_path: Path,
+ powershell_path: Path,
+ version: str,
+ *,
+ state_path: Path | None = None,
+ allow_newer: bool = False,
+) -> tuple[Path, ...]:
+ requested = version_tuple(version)
+ current = {
+ shell_path: read_version(shell_path, SHELL_VERSION),
+ powershell_path: read_version(powershell_path, POWERSHELL_VERSION),
+ }
+ if state_path is not None:
+ state_version = state_path.read_text(encoding="utf-8").strip()
+ version_tuple(state_version)
+ current[state_path] = state_version
+ if len(set(current.values())) != 1:
+ rendered = ", ".join(f"{path}={value}" for path, value in current.items())
+ raise InstallerVersionError(f"baked installer versions disagree: {rendered}")
+
+ installed = version_tuple(next(iter(current.values())))
+ if installed > requested:
+ if allow_newer:
+ return ()
+ raise InstallerVersionError(
+ f"refusing to move baked installer version backward "
+ f"from {next(iter(current.values()))} to {version}"
+ )
+
+ changed: list[Path] = []
+ for path, pattern in (
+ (shell_path, SHELL_VERSION),
+ (powershell_path, POWERSHELL_VERSION),
+ ):
+ if _replace_version(path, pattern, version):
+ changed.append(path)
+ if state_path is not None and _replace_state_version(state_path, version):
+ changed.append(state_path)
+ return tuple(changed)
+
+
+def main(argv: Sequence[str] | None = None) -> int:
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--version", required=True)
+ parser.add_argument("--shell-path", type=Path, required=True)
+ parser.add_argument("--powershell-path", type=Path, required=True)
+ parser.add_argument(
+ "--state-path",
+ type=Path,
+ help="published-version state file to update with the public installers",
+ )
+ parser.add_argument(
+ "--allow-newer",
+ action="store_true",
+ help="leave a newer, already-published baked version unchanged",
+ )
+ args = parser.parse_args(argv)
+
+ try:
+ changed = update_installer_versions(
+ args.shell_path,
+ args.powershell_path,
+ args.version,
+ state_path=args.state_path,
+ allow_newer=args.allow_newer,
+ )
+ except (InstallerVersionError, OSError) as error:
+ parser.error(str(error))
+
+ if changed:
+ for path in changed:
+ print(f"updated {path} to {args.version}")
+ else:
+ print(f"installer baked version already satisfies {args.version}")
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/.github/scripts/validate_release_versions.py b/.github/scripts/validate_release_versions.py
index 8435903494..42be5fed9e 100644
--- a/.github/scripts/validate_release_versions.py
+++ b/.github/scripts/validate_release_versions.py
@@ -34,6 +34,29 @@ def require_equal(product: str, expected: str, values: dict[str, str]) -> None:
raise VersionError(f"{product} expects {expected}; mismatched sources: {details}")
+def stable_version_tuple(version: str) -> tuple[int, int, int]:
+ if not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+", version):
+ raise VersionError(f"expected an exact stable x.y.z version, got {version!r}")
+ major, minor, patch = version.split(".")
+ return int(major), int(minor), int(patch)
+
+
+def driver_installer_versions(root: Path) -> dict[str, str]:
+ base = root / "libs/cua-driver"
+ return {
+ ".github/release-state/cua-driver-rs-published-version": (
+ root / ".github/release-state/cua-driver-rs-published-version"
+ ).read_text().strip(),
+ "scripts/_install-rust.sh": read_match(
+ base / "scripts/_install-rust.sh", r'^CUA_DRIVER_RS_BAKED_VERSION="([^"]+)"'
+ ),
+ "scripts/install.ps1": read_match(
+ base / "scripts/install.ps1",
+ r'^\$Script:CuaDriverRsBakedVersion\s*=\s*"([^"]+)"',
+ ),
+ }
+
+
def driver_versions(root: Path) -> tuple[str, dict[str, str]]:
base = root / "libs/cua-driver"
docs = root / "docs/content/docs/reference/cua-driver"
@@ -57,13 +80,6 @@ def driver_versions(root: Path) -> tuple[str, dict[str, str]]:
"typescript/package-lock.json:root": str(
typescript_lock["packages"][""]["version"]
),
- "scripts/_install-rust.sh": read_match(
- base / "scripts/_install-rust.sh", r'^CUA_DRIVER_RS_BAKED_VERSION="([^"]+)"'
- ),
- "scripts/install.ps1": read_match(
- base / "scripts/install.ps1",
- r'^\$Script:CuaDriverRsBakedVersion\s*=\s*"([^"]+)"',
- ),
"rust/Skills/cua-driver/SKILL.md": read_match(
base / "rust/Skills/cua-driver/SKILL.md",
r"^version:\s*([^\s#]+)",
@@ -125,6 +141,14 @@ def validate(root: Path, product: str) -> None:
expected, values = driver_versions(root)
values[".release-please-manifest.json"] = str(manifest["libs/cua-driver"])
require_equal("Cua Driver", expected, values)
+ installers = driver_installer_versions(root)
+ installer_version = next(iter(installers.values()))
+ require_equal("Cua Driver baked installers", installer_version, installers)
+ if stable_version_tuple(installer_version) > stable_version_tuple(expected):
+ raise VersionError(
+ f"Cua Driver baked installers advertise {installer_version}, "
+ f"ahead of source release {expected}"
+ )
if product in {"all", "lume"}:
expected, values = lume_versions(root)
values[".release-please-manifest.json"] = str(manifest["libs/lume"])
diff --git a/.github/workflows/cd-rust-cua-driver.yml b/.github/workflows/cd-rust-cua-driver.yml
index 9eaddfcfd6..4695c03b6a 100644
--- a/.github/workflows/cd-rust-cua-driver.yml
+++ b/.github/workflows/cd-rust-cua-driver.yml
@@ -588,6 +588,17 @@ jobs:
fetch-depth: 0
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.publish && format('refs/tags/cua-driver-rs-v{0}', inputs.version) || github.ref }}
+ # Recovery dispatches may target an immutable tag created before the
+ # current release tooling existed. Keep release inputs pinned to that tag,
+ # but run orchestration helpers from the exact workflow revision that was
+ # dispatched.
+ - name: Check out release control tooling
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ github.workflow_sha }}
+ path: release-control
+ persist-credentials: false
+
- name: Determine version
id: version
run: |
@@ -617,6 +628,7 @@ jobs:
- name: Stage release files
run: |
+ VERSION="${{ steps.version.outputs.version }}"
mkdir -p release-upload
find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) \
-exec cp {} release-upload/ \;
@@ -639,6 +651,10 @@ jobs:
cp libs/cua-driver/scripts/install.sh release-upload/install.sh
cp libs/cua-driver/scripts/install.ps1 release-upload/install.ps1
cp libs/cua-driver/scripts/_install-rust.sh release-upload/_install-rust.sh
+ python3 release-control/.github/scripts/update_cua_driver_installer_version.py \
+ --version "$VERSION" \
+ --shell-path release-upload/_install-rust.sh \
+ --powershell-path release-upload/install.ps1
# Uninstaller scripts — single canonical file per shell (no
# `_uninstall-rust.sh` helper). uninstall.sh handles Rust (the only
@@ -652,7 +668,6 @@ jobs:
# `cua-driver skills install`. The .md files are identical across
# OS so we publish one asset per release tag. Naming matches the
# versioned binary tarballs.
- VERSION="${{ steps.version.outputs.version }}"
# Asset name keeps the `cua-driver-rs-v*` prefix for backward
# compat with the URL skills.rs constructs.
#
@@ -743,3 +758,110 @@ jobs:
--body release-metadata/release-body.md \
--asset-dir release-upload \
--prerelease
+
+ - name: Verify the release and every staged asset are public
+ env:
+ GH_TOKEN: ${{ github.token }}
+ TAG: ${{ steps.version.outputs.tag }}
+ run: |
+ find release-upload -maxdepth 1 -type f -printf '%f\n' | sort -u \
+ > "${RUNNER_TEMP}/expected-release-assets.txt"
+ for ATTEMPT in 1 2 3 4 5; do
+ RELEASE_ID=$(gh api \
+ "repos/${{ github.repository }}/releases/tags/${TAG}" \
+ --jq 'select(.draft == false and .published_at != null) | .id' \
+ 2>/dev/null || true)
+ if [ -n "$RELEASE_ID" ]; then
+ gh api --paginate \
+ "repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?per_page=100" \
+ --jq '.[].name' | sort -u \
+ > "${RUNNER_TEMP}/published-release-assets.txt"
+ comm -23 \
+ "${RUNNER_TEMP}/expected-release-assets.txt" \
+ "${RUNNER_TEMP}/published-release-assets.txt" \
+ > "${RUNNER_TEMP}/missing-release-assets.txt"
+ if [ ! -s "${RUNNER_TEMP}/missing-release-assets.txt" ]; then
+ echo "Release ${TAG} and every staged asset are public."
+ exit 0
+ fi
+ fi
+ echo "Release visibility check ${ATTEMPT}/5 is incomplete; retrying."
+ sleep "$((ATTEMPT * 2))"
+ done
+
+ echo "Release ${TAG} is not public with every staged asset." >&2
+ if [ -s "${RUNNER_TEMP}/missing-release-assets.txt" ]; then
+ echo "Missing assets:" >&2
+ sed 's/^/ - /' "${RUNNER_TEMP}/missing-release-assets.txt" >&2
+ fi
+ exit 1
+
+ - name: Generate post-publication GitHub App token
+ id: post-publish-app-token
+ uses: actions/create-github-app-token@v1
+ with:
+ app-id: ${{ secrets.RELEASE_APP_ID }}
+ private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
+ owner: ${{ github.repository_owner }}
+ repositories: ${{ github.event.repository.name }}
+
+ - name: Advance public installer version on main
+ env:
+ GH_TOKEN: ${{ steps.post-publish-app-token.outputs.token }}
+ VERSION: ${{ steps.version.outputs.version }}
+ run: |
+ git remote set-url origin \
+ "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git"
+ TEMP_BRANCH="post-publish-installer-${GITHUB_RUN_ID}"
+
+ for ATTEMPT in 1 2 3 4 5; do
+ echo "Advancing public installers to ${VERSION} (attempt ${ATTEMPT}/5)"
+ git fetch origin main
+ UPDATE_ROOT="${RUNNER_TEMP}/cua-installer-version-${ATTEMPT}"
+ git worktree add --detach "$UPDATE_ROOT" origin/main
+
+ python3 release-control/.github/scripts/update_cua_driver_installer_version.py \
+ --version "$VERSION" \
+ --shell-path "$UPDATE_ROOT/libs/cua-driver/scripts/_install-rust.sh" \
+ --powershell-path "$UPDATE_ROOT/libs/cua-driver/scripts/install.ps1" \
+ --state-path "$UPDATE_ROOT/.github/release-state/cua-driver-rs-published-version" \
+ --allow-newer
+
+ if git -C "$UPDATE_ROOT" diff --quiet -- \
+ .github/release-state/cua-driver-rs-published-version \
+ libs/cua-driver/scripts/_install-rust.sh \
+ libs/cua-driver/scripts/install.ps1; then
+ echo "Public installers already advertise ${VERSION} or newer."
+ exit 0
+ fi
+
+ bash -n "$UPDATE_ROOT/libs/cua-driver/scripts/_install-rust.sh"
+ python3 release-control/.github/scripts/validate_release_versions.py \
+ --repo-root "$UPDATE_ROOT" \
+ --product driver
+ git -C "$UPDATE_ROOT" diff --check
+ git -C "$UPDATE_ROOT" config user.name "trycua-release[bot]"
+ git -C "$UPDATE_ROOT" config user.email \
+ "trycua-release[bot]@users.noreply.github.com"
+ git -C "$UPDATE_ROOT" add \
+ .github/release-state/cua-driver-rs-published-version \
+ libs/cua-driver/scripts/_install-rust.sh \
+ libs/cua-driver/scripts/install.ps1
+ git -C "$UPDATE_ROOT" commit \
+ -m "chore(cua-driver): advance published installer version to ${VERSION} [skip ci]"
+ COMMIT_SHA=$(git -C "$UPDATE_ROOT" rev-parse HEAD)
+
+ git push origin "${COMMIT_SHA}:refs/heads/${TEMP_BRANCH}" --force
+ if gh api -X PATCH \
+ "/repos/${{ github.repository }}/git/refs/heads/main" \
+ -f sha="$COMMIT_SHA" \
+ -F force=false; then
+ git push origin --delete "$TEMP_BRANCH" || true
+ echo "Public installers now advertise ${VERSION}."
+ exit 0
+ fi
+ echo "main advanced concurrently; retrying from its new head."
+ done
+
+ echo "Could not advance the public installers after 5 attempts." >&2
+ exit 1
diff --git a/libs/cua-driver/scripts/_install-rust.sh b/libs/cua-driver/scripts/_install-rust.sh
index 406727b551..13e99a497d 100644
--- a/libs/cua-driver/scripts/_install-rust.sh
+++ b/libs/cua-driver/scripts/_install-rust.sh
@@ -501,7 +501,7 @@ done
#
# Version is resolved in priority order:
# 1. CUA_DRIVER_RS_VERSION env var (explicit pin)
-# 2. CUA_DRIVER_RS_BAKED_VERSION below (updated in the release PR)
+# 2. CUA_DRIVER_RS_BAKED_VERSION below (updated after release publication)
# 3. GitHub Releases API (fallback for dev / un-baked checkouts;
# unauthenticated = 60 req/hr per IP)
#
@@ -512,8 +512,8 @@ done
# checkouts) or when the baked version turns out to have no downloadable
# asset — see the recovery at the download step below.
#
-# ~~~ BAKED_VERSION: auto-updated in the release PR — do not edit ~~~
-CUA_DRIVER_RS_BAKED_VERSION="0.14.0" # x-release-please-version
+# ~~~ BAKED_VERSION: auto-updated after release publication — do not edit ~~~
+CUA_DRIVER_RS_BAKED_VERSION="0.14.0" # published-installer-version
# ~~~ END_BAKED_VERSION ~~~
# Run API requests with an optional token. Keep the header construction here
@@ -602,12 +602,10 @@ resolve_latest_version_from_api() {
}
# Where VERSION came from. A missing asset is fatal for an explicit pin (the
-# user named that version) but recoverable for the baked constant, which is
-# routinely ahead of reality: merging the Release Please pull request bumps it
-# on `main` and creates the tag, yet the release starts as an unpublished draft
-# whose assets stay undownloadable until the CD build publishes it. cua.ai
-# serves this script from `main`, so the public one-liner points at a version
-# nobody can fetch for the length of every release build.
+# user named that version) but recoverable for the baked constant. The normal
+# CD path advances it only after every staged release asset is public; fallback
+# remains defense in depth for manual edits, asset removal, or an interrupted
+# legacy release flow.
if [[ -n "${CUA_DRIVER_RS_VERSION:-}" ]]; then
VERSION_SOURCE="pin"
TAG="${TAG_PREFIX}${CUA_DRIVER_RS_VERSION#v}"
@@ -710,10 +708,9 @@ download_release_tarball() {
DOWNLOAD_STATUS=0
download_release_tarball "$VERSION" || DOWNLOAD_STATUS=$?
if (( DOWNLOAD_STATUS != 0 )); then
- # Almost always the publish-lag window described at the baked constant: it
- # is already live on `main` while its release is still an unpublished draft.
- # Without this recovery the default `curl | bash` install fails outright for
- # the length of every release build, with no way through but a version pin.
+ # Defense in depth for a manually advanced constant, removed asset, or
+ # interrupted legacy release flow. The normal CD path updates this constant
+ # only after every staged asset is publicly visible.
if [[ "$VERSION_SOURCE" != "baked" || "$DOWNLOAD_STATUS" != "44" ]]; then
err "download failed; try CUA_DRIVER_RS_VERSION=<version> to pin a specific release"
exit 1
diff --git a/libs/cua-driver/scripts/install.ps1 b/libs/cua-driver/scripts/install.ps1
index 042955838b..636b484136 100644
--- a/libs/cua-driver/scripts/install.ps1
+++ b/libs/cua-driver/scripts/install.ps1
@@ -102,10 +102,9 @@ $TagPrefix = "cua-driver-rs-v"
$BinaryName = "cua-driver.exe"
$ThemeBinaryName = "cua-cursor-theme.exe"
-# Baked-version constant — kept in lock-step with the latest published
-# cua-driver-rs-v* release tag by the Release Please release pull request
-# (see .github/workflows/cd-rust-cua-driver.yml). The sentinel-block
-# markers identify this line for Release Please's generic version updater.
+# Baked-version constant — advanced by the Cua Driver CD workflow only after
+# the matching GitHub release and all staged assets are public. The sentinel
+# markers identify this line for the post-publication updater.
#
# Precedence at resolve time: $env:CUA_DRIVER_RS_VERSION > -Release arg >
# this baked value > GitHub Releases API. Baked means the `irm | iex`
@@ -113,8 +112,8 @@ $ThemeBinaryName = "cua-cursor-theme.exe"
# only consulted as a fallback when this script is run from a branch
# where the baked line hasn't been updated yet.
#
-# ~~~ BAKED_VERSION: auto-updated in the release PR — do not edit ~~~
-$Script:CuaDriverRsBakedVersion = "0.14.0" # x-release-please-version
+# ~~~ BAKED_VERSION: auto-updated after release publication — do not edit ~~~
+$Script:CuaDriverRsBakedVersion = "0.14.0" # published-installer-version
# ~~~ END_BAKED_VERSION ~~~
$CursorThemeRequiredFrom = [version]"0.12.7"
@@ -854,15 +853,11 @@ function Invoke-OldReleasesGc {
# 'env' / 'release-arg' — the user named an exact version. Installing some
# other version would silently defy an explicit instruction, so a
# missing asset must stay fatal.
-# 'baked' — recoverable, and routinely wrong for a window on
-# every release. Merging the Release Please pull request bumps the
-# constant on `main` and creates the tag, but the release it creates is
-# a *draft*: its assets only become downloadable when the CD workflow
-# finishes building and publishes it. Since cua.ai serves this script
-# from `main`, the public one-liner advertises a version nobody can
-# download for the length of that build. Observed windows on
-# cua-driver-rs releases range from ~12 minutes to ~3.5 hours. Falling
-# back to the newest published release keeps installs working through it.
+# 'baked' — normally the newest fully published release. A
+# confirmed missing asset can still happen after manual edits, release
+# asset removal, or an interrupted legacy release flow. Falling back to
+# the newest published component release keeps the default installer
+# recoverable without weakening explicit version pins.
# 'api' — already the API's answer; nothing left to fall
# back to.
$Script:CuaDriverRsVersionSource = $null
@@ -1069,11 +1064,9 @@ function Get-ReleaseAsset([string]$version, [string]$archLabel, [string]$destDir
}
if ($download.Missing -and $Script:CuaDriverRsVersionSource -eq 'baked') {
- # Almost always the publish-lag window described above: the constant is
- # already live on `main` while its release is still an unpublished
- # draft. Without this recovery the default `irm | iex` install fails
- # outright for the length of every release build, with no way through
- # but an explicit version pin.
+ # Defense in depth for a manually advanced constant, removed asset, or
+ # interrupted legacy release flow. The normal CD path updates this
+ # constant only after every staged asset is publicly visible.
$apiVersion = Get-LatestVersionFromApi
if (-not $apiVersion) {
$missingDetail = "no published fallback could be resolved"
diff --git a/libs/cua-driver/scripts/tests/test_install_version_fallback.py b/libs/cua-driver/scripts/tests/test_install_version_fallback.py
index 78b2a35a0e..98bedea507 100644
--- a/libs/cua-driver/scripts/tests/test_install_version_fallback.py
+++ b/libs/cua-driver/scripts/tests/test_install_version_fallback.py
@@ -1,21 +1,18 @@
"""Installer release-resolution guards.
-Every release opens a window where the baked version constant points at assets
-nobody can download yet. Merging the Release Please pull request bumps the
-constant on `main` and creates the tag, but the release it creates is a draft;
-its assets only become fetchable once the CD workflow finishes building and
-publishes it. cua.ai serves both installers straight from `main`, so the public
-one-liner advertises an undownloadable version for the length of that build --
-observed windows on cua-driver-rs releases run from ~12 minutes to ~3.5 hours.
-
-The baked value must therefore degrade to the GitHub Releases API rather than
-fail the install. An explicit pin (CUA_DRIVER_RS_VERSION, -Release) is the
+The release workflow advances the baked version only after every staged asset
+is public. The runtime fallback remains defense in depth for manual edits,
+asset removal, interrupted legacy releases, and installer copies from older
+branches where a baked version may still point at an unavailable asset.
+
+A missing baked value may therefore degrade to the GitHub Releases API rather
+than fail the install. An explicit pin (CUA_DRIVER_RS_VERSION, -Release) is the
opposite case: the user named one version, so a missing asset must stay fatal
rather than silently installing a different one.
-Version *agreement* across the checked-in sources is not tested here --
-.github/scripts/validate_release_versions.py already owns that. It cannot cover
-these invariants, because at merge time the release genuinely is unpublished.
+Published installer-state agreement is owned by
+.github/scripts/validate_release_versions.py; this module tests runtime
+resolution and failure semantics.
"""
from __future__ import annotations
diff --git a/release-please-config.json b/release-please-config.json
index 9cd319d947..ead6ef14cb 100644
--- a/release-please-config.json
+++ b/release-please-config.json
@@ -48,14 +48,6 @@
"path": "typescript/package-lock.json",
"jsonpath": "$.packages[''].version"
},
- {
- "type": "generic",
- "path": "scripts/_install-rust.sh"
- },
- {
- "type": "generic",
- "path": "scripts/install.ps1"
- },
{
"type": "generic",
"path": "rust/Skills/cua-driver/SKILL.md"