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.

ci(release-please): tag only the merged release PR's own component (CUA-3198) (#6410)

cua-agents[bot]478b1a384b80
diff --git a/.github/scripts/release_please_tag_guard.cjs b/.github/scripts/release_please_tag_guard.cjs
new file mode 100644
index 0000000000..8acff5955c
--- /dev/null
+++ b/.github/scripts/release_please_tag_guard.cjs
@@ -0,0 +1,126 @@
+// Predict, with the pinned Release Please engine, which components a merged
+// release PR will tag, and repair a PR body that would tag the wrong ones.
+//
+// Release Please reads each component's version from the merged PR body. A
+// single-component body parses only when its notes block starts with the
+// version heading ("## [0.20.0](...)"). Text inserted above that heading makes
+// the body parse to zero releases, and Release Please then falls back to the
+// PR title's version for every configured component. On 3 Nov 2026 that
+// tagged 13 unrelated components v0.20.0 from the cua-spaces 0.20.0 PR (#6350).
+//
+// node release_please_tag_guard.cjs check <pr.json> prints the components it would tag
+// node release_please_tag_guard.cjs repair <pr.json> prints a repaired body, or exits 1
+//
+// pr.json is `gh pr view --json number,title,headRefName,body,mergeCommit`.
+// NODE_PATH must point at node_modules holding [email protected].
+const fs = require('node:fs');
+const path = require('node:path');
+const { Manifest } = require('release-please/build/src/manifest');
+const { BranchName } = require('release-please/build/src/util/branch-name');
+
+const root = path.resolve(__dirname, '../..');
+const CONFIG = 'release-please-config.json';
+const MANIFEST = '.release-please-manifest.json';
+const DELIMITER = '---';
+// Release Please 17.3.0's COMPARE_REGEX, matched per line.
+const VERSION_HEADING = /^#{2,} \[?\d+\.\d+\.\d+[^\]]*\]?/;
+
+function offlineGithub(repoRoot) {
+ return {
+ repository: { owner: 'trycua', repo: 'cua', defaultBranch: 'main' },
+ async getFileJson(file) {
+ return JSON.parse(fs.readFileSync(path.join(repoRoot, file), 'utf8'));
+ },
+ };
+}
+
+function quietLogger() {
+ const noop = () => {};
+ return { error: noop, warn: noop, info: noop, debug: noop, trace: noop };
+}
+
+// The engine's own candidate releases for one merged PR: Manifest.buildReleases
+// with the PR search replaced by this one PR.
+async function wouldTag(pr, repoRoot = root) {
+ const { setLogger } = require('release-please/build/src/util/logger');
+ setLogger(quietLogger());
+ const manifest = await Manifest.fromManifest(offlineGithub(repoRoot), 'main', CONFIG, MANIFEST);
+ const merged = {
+ number: pr.number,
+ title: pr.title,
+ headBranchName: pr.headRefName,
+ baseBranchName: 'main',
+ body: pr.body,
+ labels: ['autorelease: pending'],
+ files: [],
+ sha: (pr.mergeCommit && pr.mergeCommit.oid) || 'f'.repeat(40),
+ };
+ manifest.findMergedReleasePullRequests = async function* () { yield merged; };
+ const releases = await manifest.buildReleases();
+ return releases.map(r => ({ path: r.path, tag: r.tag.toString() }));
+}
+
+function branchComponent(pr) {
+ const branch = BranchName.parse(pr.headRefName, quietLogger());
+ return branch ? branch.component || '' : '';
+}
+
+function configuredPathFor(component, repoRoot = root) {
+ const config = JSON.parse(fs.readFileSync(path.join(repoRoot, CONFIG), 'utf8'));
+ return Object.keys(config.packages).find(p => config.packages[p].component === component);
+}
+
+// Every candidate must belong to the PR's own component.
+async function check(pr, repoRoot = root) {
+ const component = branchComponent(pr);
+ const ownPath = configuredPathFor(component, repoRoot);
+ const releases = await wouldTag(pr, repoRoot);
+ const stray = releases.filter(r => r.path !== ownPath);
+ return { number: pr.number, component, path: ownPath || null, releases, stray, ok: stray.length === 0 };
+}
+
+// Move the first version heading to the top of the notes block, keeping every
+// line of the PR body. Returns null when the body has no notes block or no
+// version heading to move.
+function repairBody(body) {
+ const lines = body.trim().replace(/\r\n/g, '\n').split('\n');
+ const first = lines.indexOf(DELIMITER);
+ if (first === -1) return null;
+ let last = lines.lastIndexOf(DELIMITER);
+ if (last === first) return null;
+ const content = lines.slice(first + 1, last);
+ const heading = content.findIndex(line => VERSION_HEADING.test(line));
+ if (heading === -1) return null;
+ const before = content.slice(0, heading);
+ if (before.every(line => line.trim() === '')) return body;
+ const notes = [content[heading], '', ...before, ...content.slice(heading + 1)];
+ return [...lines.slice(0, first + 1), '', '', ...notes, ...lines.slice(last)].join('\n');
+}
+
+async function main() {
+ const [command, file] = process.argv.slice(2);
+ if (!['check', 'repair'].includes(command) || !file) {
+ console.error('usage: release_please_tag_guard.cjs check|repair <pr.json>');
+ process.exit(2);
+ }
+ const pr = JSON.parse(fs.readFileSync(file, 'utf8'));
+ if (command === 'check') {
+ const result = await check(pr);
+ console.log(JSON.stringify(result));
+ process.exit(result.ok ? 0 : 1);
+ }
+ const repaired = repairBody(pr.body || '');
+ if (repaired === null) process.exit(1);
+ const result = await check({ ...pr, body: repaired });
+ if (!result.ok) process.exit(1);
+ process.stdout.write(repaired);
+}
+
+module.exports = { wouldTag, check, repairBody, branchComponent };
+
+if (require.main === module) {
+ main().catch(error => {
+ console.error(error);
+ process.exit(2);
+ });
+}
diff --git a/.github/scripts/tests/fixtures/release-pr-6350-body.md b/.github/scripts/tests/fixtures/release-pr-6350-body.md
new file mode 100644
index 0000000000..3cc7f5a38e
--- /dev/null
+++ b/.github/scripts/tests/fixtures/release-pr-6350-body.md
@@ -0,0 +1,23 @@
+:robot: I have created a release *beep* *boop*
+---
+
+
+## What changes for users
+
+- Cua Spaces on a Mac that cannot run Spaces itself (for example a virtual machine) now says so in plain words and points you to another computer or your own cloud.
+- Space creates that fail now clean up the virtual machines and containers they leave behind, and say what is using a full disk.
+- Local macOS Spaces reach their virtual machine reliably, even with VPN or Local Network restrictions.
+- A downloaded update now installs when you quit the app.
+- Windows Spaces on cloud hosts, the new first-run setup (Settings, Advanced, Labs, "Try the new setup") and Secure Spaces, child Spaces and the macOS developer-tools image are experiments. They are off by default and only appear when turned on.
+
+Smoke test: update from 0.19.4 to the 0.20.0 build installed on quit, the app launched, Settings and Labs render with the new setup switch off, sign-up and sign-in worked, and the CLI reported its version and listed Spaces.
+
+## [0.20.0](https://github.com/trycua/cua/compare/cua-spaces-v0.19.4...cua-spaces-v0.20.0) (2026-11-03)
+
+
+### Features
+
+* **spaces:** Secure Spaces, child Spaces, conformance, space jobs and the macOS developer-tools image, behind experiments ([#6306](https://github.com/trycua/cua/issues/6306)) ([4715a72](https://github.com/trycua/cua/commit/4715a723a450610cdf77f688776c1fdd40660149))
+
+---
+This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
diff --git a/.github/scripts/tests/release_please_tagging_preview.cjs b/.github/scripts/tests/release_please_tagging_preview.cjs
new file mode 100644
index 0000000000..db3d47e094
--- /dev/null
+++ b/.github/scripts/tests/release_please_tagging_preview.cjs
@@ -0,0 +1,74 @@
+// Offline: a merged release PR must tag only its own component.
+//
+// Runs the pinned Release Please engine (Manifest.buildReleases) on one merged
+// PR per configured component, and on the edited cua-spaces 0.20.0 body that
+// tagged 13 other components on 3 Nov 2026 (#6350).
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+const { PullRequestBody } = require('release-please/build/src/util/pull-request-body');
+const { PullRequestTitle } = require('release-please/build/src/util/pull-request-title');
+const { BranchName } = require('release-please/build/src/util/branch-name');
+const { Version } = require('release-please/build/src/version');
+const guard = require('../release_please_tag_guard.cjs');
+
+const root = path.resolve(__dirname, '../../..');
+const config = JSON.parse(fs.readFileSync(path.join(root, 'release-please-config.json')));
+const fixture = fs.readFileSync(path.join(__dirname, 'fixtures/release-pr-6350-body.md'), 'utf8');
+
+function releasePr(component, version, notes) {
+ const body = new PullRequestBody([{ component, version: Version.parse(version), notes }]);
+ return {
+ number: 1,
+ title: PullRequestTitle.ofComponentTargetBranchVersion(component, 'main', Version.parse(version)).toString(),
+ headRefName: BranchName.ofComponentTargetBranch(component, 'main').toString(),
+ body: body.toString(),
+ };
+}
+
+function heading(component, version) {
+ return `## [${version}](https://github.com/trycua/cua/compare/${component}-v0.0.1...${component}-v${version}) (2026-11-03)\n\n\n### Bug Fixes\n\n* a fix`;
+}
+
+(async () => {
+ // A pristine Release Please PR for each component tags that component only
+ // (Perception skips GitHub releases, so it tags nothing here).
+ for (const [pkgPath, pkg] of Object.entries(config.packages)) {
+ const pr = releasePr(pkg.component, '9.9.9', heading(pkg.component, '9.9.9'));
+ const result = await guard.check(pr, root);
+ const expected = pkg['skip-github-release'] ? [] : [pkgPath];
+ assert.deepEqual(result.releases.map(r => r.path), expected, `${pkg.component}: ${JSON.stringify(result)}`);
+ assert.ok(result.ok, pkg.component);
+ }
+
+ // Notes added above the version heading: the engine tags every component.
+ const edited = {
+ number: 6350,
+ title: 'chore(main): release cua-spaces 0.20.0',
+ headRefName: 'release-please--branches--main--components--cua-spaces',
+ body: fixture,
+ };
+ const before = await guard.check(edited, root);
+ assert.equal(before.ok, false);
+ assert.ok(before.stray.length > 1, JSON.stringify(before));
+ assert.ok(before.stray.some(r => r.tag === 'cua-sdk-v0.20.0'));
+
+ // The repaired body keeps every line and tags only cua-spaces.
+ const repaired = guard.repairBody(fixture);
+ assert.notEqual(repaired, null);
+ const lines = s => s.split('\n').filter(l => l.trim()).sort();
+ assert.deepEqual(lines(repaired), lines(fixture.trim()));
+ const after = await guard.check({ ...edited, body: repaired }, root);
+ assert.ok(after.ok, JSON.stringify(after));
+ assert.deepEqual(after.releases.map(r => r.tag), ['cua-spaces-v0.20.0']);
+
+ // A pristine body is left as is, and a body with no version heading is not
+ // guessed at.
+ const pristine = releasePr('cua-sdk', '0.11.0', heading('cua-sdk', '0.11.0'));
+ assert.equal(guard.repairBody(pristine.body), pristine.body);
+ assert.equal(guard.repairBody(pristine.body.replace(/^## \[0\.11\.0\].*$/m, '## Notes')), null);
+ console.log('release PRs tag only their own component');
+})().catch(error => {
+ console.error(error);
+ process.exit(1);
+});
diff --git a/.github/scripts/tests/test_release_please_tag_guard_wiring.py b/.github/scripts/tests/test_release_please_tag_guard_wiring.py
new file mode 100644
index 0000000000..3157aa69ba
--- /dev/null
+++ b/.github/scripts/tests/test_release_please_tag_guard_wiring.py
@@ -0,0 +1,56 @@
+"""A merged release PR must tag only its own component (#6350).
+
+release_please_tagging_preview.cjs proves the guard with the pinned engine;
+these tests keep the guard wired in front of every place that tags.
+"""
+
+from __future__ import annotations
+
+import unittest
+from pathlib import Path
+
+REPO_ROOT = Path(__file__).resolve().parents[3]
+WORKFLOWS = REPO_ROOT / ".github/workflows"
+GUARD = ".github/scripts/release_please_tag_guard.cjs"
+
+
+def step(workflow: str, name: str) -> str:
+ text = (WORKFLOWS / workflow).read_text()
+ marker = f"- name: {name}\n"
+ assert marker in text, f"{workflow}: missing step {name!r}"
+ return text.split(marker, 1)[1].split("\n - ", 1)[0]
+
+
+class ReleasePleaseTagGuardWiringTest(unittest.TestCase):
+ def test_guard_runs_before_release_please_tags(self) -> None:
+ text = (WORKFLOWS / "release-please.yml").read_text()
+ guard = text.index("- name: Guard merged release PRs against tagging other components")
+ tagging = text.index("- name: Open or update automatic release pull requests")
+ self.assertLess(guard, tagging)
+ body = step("release-please.yml", "Guard merged release PRs against tagging other components")
+ # Same condition as the tagging step, so it can never be skipped alone.
+ tagging_if = step("release-please.yml", "Open or update automatic release pull requests").split("uses:", 1)[0]
+ self.assertEqual(body.split("env:", 1)[0].strip(), tagging_if.split("id: release-auto", 1)[1].strip())
+ self.assertIn('--label "autorelease: pending"', body)
+ self.assertIn(f"GUARD={GUARD}", body)
+ self.assertIn('node "$GUARD" check', body)
+ self.assertIn('node "$GUARD" repair', body)
+ self.assertIn('exit "$FAILED"', body)
+ self.assertIn("[email protected]", body)
+
+ def test_release_prs_are_checked_on_every_edit(self) -> None:
+ text = (WORKFLOWS / "ci-release-metadata.yml").read_text()
+ self.assertIn("types: [opened, edited, synchronize, reopened", text)
+ body = step("ci-release-metadata.yml", "Check that the release PR tags only its own component")
+ self.assertIn("release-please--branches--", body)
+ self.assertIn(f"GUARD={GUARD}", body)
+ self.assertIn('node "$GUARD" check', body)
+
+ def test_ci_runs_the_engine_preview(self) -> None:
+ ci = (WORKFLOWS / "ci-test-scripts.yml").read_text()
+ self.assertIn("release_please_tagging_preview.cjs", ci)
+ self.assertTrue((REPO_ROOT / ".github/scripts/tests/fixtures/release-pr-6350-body.md").is_file())
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/workflows/ci-release-metadata.yml b/.github/workflows/ci-release-metadata.yml
index 1102b36204..81d3ba5f61 100644
--- a/.github/workflows/ci-release-metadata.yml
+++ b/.github/workflows/ci-release-metadata.yml
@@ -196,6 +196,33 @@ jobs:
--output /tmp/sandbox-release-manifest.json
fi
+ # Release Please tags from this PR's body after merge. Text added above
+ # its version heading makes it tag every component (#6350), so check the
+ # current body with the same engine on every edit.
+ - name: Check that the release PR tags only its own component
+ if: >-
+ github.event.pull_request.head.repo.full_name == github.repository &&
+ startsWith(github.event.pull_request.head.ref, 'release-please--branches--')
+ env:
+ BASE_SHA: ${{ github.event.pull_request.base.sha }}
+ NPM_CONFIG_IGNORE_SCRIPTS: "true"
+ run: |
+ set -euo pipefail
+ GUARD=.github/scripts/release_please_tag_guard.cjs
+ # A release branch cut before the guard existed uses main's copy.
+ [[ -f "$GUARD" ]] || git show "$BASE_SHA:$GUARD" > "$GUARD"
+ EXPECTED_INTEGRITY='sha512-dB7HsFUpAvU1Wj9RGCINUz8Zi2qQDZiGbDEEVnJ7baNfJmk5XdYhuUFL6RcuDGjReGhp1gzY8Tc2g7vHlM4zpg=='
+ test "$(npm view [email protected] dist.integrity)" = "$EXPECTED_INTEGRITY"
+ ENGINE="$RUNNER_TEMP/release-please-engine"
+ npm install --prefix "$ENGINE" --ignore-scripts --no-audit --no-fund [email protected] > /dev/null
+ jq '{number: .pull_request.number, title: .pull_request.title,
+ headRefName: .pull_request.head.ref, body: (.pull_request.body // "")}' \
+ "$GITHUB_EVENT_PATH" > "$RUNNER_TEMP/release-pr.json"
+ if ! NODE_PATH="$ENGINE/node_modules" node "$GUARD" check "$RUNNER_TEMP/release-pr.json"; then
+ echo "::error::After merge this PR would tag other components. Keep the version heading (## [x.y.z](...)) as the first line after '---'; put added notes below it."
+ exit 1
+ fi
+
# The components release-notes.yml renders get the same preflight: a
# release PR whose changelog or contributor attribution would not render
# fails here, before its tag exists.
diff --git a/.github/workflows/ci-test-scripts.yml b/.github/workflows/ci-test-scripts.yml
index a3cadeda4d..375b2ab897 100644
--- a/.github/workflows/ci-test-scripts.yml
+++ b/.github/workflows/ci-test-scripts.yml
@@ -200,6 +200,8 @@ jobs:
node .github/scripts/tests/release_please_spaces_preview.cjs
NODE_PATH="$RUNNER_TEMP/sandbox-release-preview/node_modules" \
node .github/scripts/tests/release_please_enrolled_preview.cjs
+ NODE_PATH="$RUNNER_TEMP/sandbox-release-preview/node_modules" \
+ node .github/scripts/tests/release_please_tagging_preview.cjs
- name: Validate historical release backfill
run: python3 .github/scripts/release_backfill.py validate
diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml
index c4af570635..1283028072 100644
--- a/.github/workflows/release-please.yml
+++ b/.github/workflows/release-please.yml
@@ -116,6 +116,45 @@ jobs:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: python3 .github/scripts/mark_perception_release_prs_tagged.py
+ # Release Please reads each component's version from the merged PR body.
+ # Text above the body's version heading makes it parse to no releases, and
+ # Release Please then tags EVERY component with the PR title's version
+ # (#6350 tagged 13 components v0.20.0). Run the same engine on each
+ # merged, untagged release PR first: move the heading back to the top
+ # when that is all it takes, and stop before any tag otherwise.
+ - name: Guard merged release PRs against tagging other components
+ if: >-
+ github.event_name == 'push' ||
+ (inputs.component == 'automatic' && inputs.bump == 'automatic')
+ env:
+ GH_TOKEN: ${{ steps.app-token.outputs.token }}
+ NPM_CONFIG_IGNORE_SCRIPTS: "true"
+ run: |
+ set -euo pipefail
+ EXPECTED_INTEGRITY='sha512-dB7HsFUpAvU1Wj9RGCINUz8Zi2qQDZiGbDEEVnJ7baNfJmk5XdYhuUFL6RcuDGjReGhp1gzY8Tc2g7vHlM4zpg=='
+ test "$(npm view [email protected] dist.integrity)" = "$EXPECTED_INTEGRITY"
+ ENGINE="$RUNNER_TEMP/release-please-engine"
+ npm install --prefix "$ENGINE" --ignore-scripts --no-audit --no-fund [email protected] > /dev/null
+ export NODE_PATH="$ENGINE/node_modules"
+ GUARD=.github/scripts/release_please_tag_guard.cjs
+ FAILED=0
+ for number in $(gh pr list --state merged --base main --label "autorelease: pending" \
+ --limit 100 --json number --jq '.[].number'); do
+ PR="$RUNNER_TEMP/release-pr-$number.json"
+ gh pr view "$number" --json number,title,headRefName,body,mergeCommit > "$PR"
+ if node "$GUARD" check "$PR"; then
+ continue
+ fi
+ if node "$GUARD" repair "$PR" > "$PR.md"; then
+ gh pr edit "$number" --body-file "$PR.md"
+ echo "::warning::Release PR #$number: moved its version heading to the top of the notes so only its own component is tagged."
+ else
+ echo "::error::Release PR #$number would tag components it does not release. Edit its body so the version heading (## [x.y.z](...)) is the first line after '---', then rerun this workflow."
+ FAILED=1
+ fi
+ done
+ exit "$FAILED"
+
# release-please-action v4.4.1, embedding release-please 17.3.0.
- name: Open or update automatic release pull requests
id: release-auto
diff --git a/AGENTS.md b/AGENTS.md
index a2893c06b2..1bdd577da2 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -147,6 +147,11 @@ files and query its current GitHub title. Correct the title yourself when the
scope or release impact changed during implementation, and wait for
`CI: Release metadata` to pass. Do not leave title correction for a maintainer.
+When you add notes to a Release Please PR body, put them below its version
+heading (`## [x.y.z](...)`), never above it. Release Please reads the version
+from that heading; with text above it, it tags every component with the PR's
+version (#6350). `CI: Release metadata` and the release workflow both check this.
+
## Monorepo component release resolution
Cua is a monorepo with independent component release streams. Never use