Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(release): validate prerelease documentation versions

vastsaf4b73ff6296a
diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml
index 2099a04c0..135a5e766 100644
--- a/.github/workflows/docs-check.yml
+++ b/.github/workflows/docs-check.yml
@@ -4,8 +4,8 @@ name: Docs check
# This workflow runs the documentation checks: the English/Chinese pair check,
# the whole-tree page/ADR check, the AGENTS.md/CLAUDE.md policy-sync gate, and
# a VitePress build, which fails on a dead link anywhere in the tree.
-# `check:release-docs` stays out of CI on purpose because it intentionally
-# fails on rc versions.
+# `check:release-docs` stays out of CI on purpose because prerelease branches
+# must supply the stable documentation version explicitly.
on:
push:
diff --git a/scripts/README.md b/scripts/README.md
index 1074b94a4..e932cf6dc 100644
--- a/scripts/README.md
+++ b/scripts/README.md
@@ -70,7 +70,8 @@ and on manual dispatch, skipping both when a change touches only `docs/**` or
`.github/workflows/docs-check.yml` covers the paths `ci.yml` ignores: it runs
`pnpm docs:check` (the docs locale pair check) when `docs/**`, the READMEs, the
shared changelog sources, or the check scripts change. `check:release-docs` is
-deliberately not in CI because it fails on rc versions by design.
+deliberately not in CI because release branches must pass it with the stable
+version explicitly supplied for a prerelease preview.
`.github/workflows/release.yml` builds on a `v*.*.*` tag. A `verify` job first
repeats the `ci.yml` checks (a tag push does not trigger `ci.yml`), and the
diff --git a/scripts/check-release-docs.mjs b/scripts/check-release-docs.mjs
index e72b5f06d..6101075a2 100644
--- a/scripts/check-release-docs.mjs
+++ b/scripts/check-release-docs.mjs
@@ -31,6 +31,7 @@ import {
import { createRequire } from "node:module";
import { fileURLToPath, pathToFileURL } from "node:url";
import path from "node:path";
+import { resolveReleaseDocumentCheck } from "./release-version-check.mjs";
const root = fileURLToPath(new URL("..", import.meta.url));
const read = (relPath) => readFileSync(path.join(root, relPath), "utf8");
@@ -43,8 +44,16 @@ if (requested && !/^\d+\.\d+\.\d+(-[0-9A-Za-z.]+)?$/.test(requested)) {
process.exit(1);
}
-const version = requested ?? JSON.parse(read("package.json")).version;
-const releaseLine = `${version.split(".").slice(0, 2).join(".")}.x`;
+const currentVersion = JSON.parse(read("package.json")).version;
+const { documentVersion, surfaceVersion, isPrereleasePreview } = resolveReleaseDocumentCheck(
+ currentVersion,
+ requested,
+);
+const releaseLine = `${documentVersion.split(".").slice(0, 2).join(".")}.x`;
+
+if (requested && !isPrereleasePreview && currentVersion !== requested) {
+ fail("package.json", `version is ${currentVersion}, expected ${requested}`);
+}
// 1. Version surfaces.
const packageFiles = ["package.json", "docs/package.json"];
@@ -56,7 +65,7 @@ for (const group of ["apps", "packages"]) {
}
for (const relPath of packageFiles) {
const found = JSON.parse(read(relPath)).version;
- if (found !== version) fail(relPath, `version is ${found}, expected ${version}`);
+ if (found !== surfaceVersion) fail(relPath, `version is ${found}, expected ${surfaceVersion}`);
}
for (const [relPath, pattern, label] of [
@@ -65,7 +74,9 @@ for (const [relPath, pattern, label] of [
["packages/shared/src/protocol.ts", /export const APP_VERSION = "([^"]+)"/, "APP_VERSION"],
]) {
const found = read(relPath).match(pattern)?.[1];
- if (found !== version) fail(relPath, `${label} is ${found ?? "missing"}, expected ${version}`);
+ if (found !== surfaceVersion) {
+ fail(relPath, `${label} is ${found ?? "missing"}, expected ${surfaceVersion}`);
+ }
}
// 2. Bundled models.dev snapshot.
@@ -144,14 +155,14 @@ if (catalogs) {
fail("packages/shared/src/changelog.ts", `the ${locale} catalog is empty`);
continue;
}
- if (!entries.some((entry) => entry.version === version)) {
- fail("packages/shared/src/changelog.ts", `${locale} has no entry for ${version}`);
+ if (!entries.some((entry) => entry.version === documentVersion)) {
+ fail("packages/shared/src/changelog.ts", `${locale} has no entry for ${documentVersion}`);
continue;
}
- if (entries[0].version !== version) {
+ if (entries[0].version !== documentVersion) {
fail(
"packages/shared/src/changelog.ts",
- `${locale} lists ${entries[0].version} first; ${version} must be newest-first`,
+ `${locale} lists ${entries[0].version} first; ${documentVersion} must be newest-first`,
);
}
if (entries.map((entry) => entry.version).join("\u0000") !== expectedVersions.join("\u0000")) {
@@ -175,8 +186,11 @@ if (catalogs) {
}
// 3. Catalog test pins the newest version.
-if (!read("packages/shared/src/changelog.test.ts").includes(`"${version}"`)) {
- fail("packages/shared/src/changelog.test.ts", `expected version list does not contain ${version}`);
+if (!read("packages/shared/src/changelog.test.ts").includes(`"${documentVersion}"`)) {
+ fail(
+ "packages/shared/src/changelog.test.ts",
+ `expected version list does not contain ${documentVersion}`,
+ );
}
// 4. READMEs declare the current release line.
@@ -187,9 +201,10 @@ for (const relPath of ["README.md", "README.zh-CN.md"]) {
}
if (failures.length > 0) {
- console.error(`Release documentation is not aligned with ${version}:`);
+ console.error(`Release documentation is not aligned with ${documentVersion}:`);
for (const failure of failures) console.error(` - ${failure}`);
console.error("\nSee docs/spec/06-delivery/06-release-runbook.md section 4.1.");
process.exit(1);
}
-console.log(`Release documentation is aligned with ${version} (${releaseLine} line).`);
+const previewNote = isPrereleasePreview ? ` for ${surfaceVersion}` : "";
+console.log(`Release documentation is aligned with ${documentVersion}${previewNote} (${releaseLine} line).`);
diff --git a/scripts/release-version-check.mjs b/scripts/release-version-check.mjs
new file mode 100644
index 000000000..ba22e6d89
--- /dev/null
+++ b/scripts/release-version-check.mjs
@@ -0,0 +1,13 @@
+export function resolveReleaseDocumentCheck(currentVersion, requestedVersion) {
+ const documentVersion = requestedVersion ?? currentVersion;
+ const isPrereleasePreview =
+ requestedVersion !== undefined &&
+ currentVersion !== documentVersion &&
+ currentVersion.startsWith(`${documentVersion}-`);
+
+ return {
+ documentVersion,
+ surfaceVersion: isPrereleasePreview ? currentVersion : documentVersion,
+ isPrereleasePreview,
+ };
+}
diff --git a/scripts/release-version-check.test.mjs b/scripts/release-version-check.test.mjs
new file mode 100644
index 000000000..b992b3711
--- /dev/null
+++ b/scripts/release-version-check.test.mjs
@@ -0,0 +1,27 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { resolveReleaseDocumentCheck } from "./release-version-check.mjs";
+
+test("checks a stable release against one aligned version", () => {
+ assert.deepEqual(resolveReleaseDocumentCheck("0.15.2", "0.15.2"), {
+ documentVersion: "0.15.2",
+ surfaceVersion: "0.15.2",
+ isPrereleasePreview: false,
+ });
+});
+
+test("checks a prerelease preview against its stable documentation version", () => {
+ assert.deepEqual(resolveReleaseDocumentCheck("0.15.2-beta.2", "0.15.2"), {
+ documentVersion: "0.15.2",
+ surfaceVersion: "0.15.2-beta.2",
+ isPrereleasePreview: true,
+ });
+});
+
+test("does not hide a mismatched requested version", () => {
+ assert.deepEqual(resolveReleaseDocumentCheck("0.15.2-beta.2", "0.15.1"), {
+ documentVersion: "0.15.1",
+ surfaceVersion: "0.15.1",
+ isPrereleasePreview: false,
+ });
+});