Compare commits

..
Author SHA1 Message Date
drakezhang 50a64d45c0 chore(release): 0.2.0 2026-09-02 18:08:34 +08:00
3 changed files with 27 additions and 40 deletions
+2
View File
@@ -9,6 +9,8 @@ Starting from 0.2.0, CLI / Extension / DSH Plugin share the same version number.
## [0.2.0] - 2026-09-02 ## [0.2.0] - 2026-09-02
## [0.2.0] - 2026-09-XX
### Added ### Added
- File transfer: upload and download support across CLI, Extension, and DSH Plugin - File transfer: upload and download support across CLI, Extension, and DSH Plugin
- File transfer: drag-and-drop upload (`drop-to-upload`) - File transfer: drag-and-drop upload (`drop-to-upload`)
@@ -122,8 +122,8 @@ describe("App", () => {
expect(screen.queryByText(/^扩展 v/)).toBeNull(); expect(screen.queryByText(/^扩展 v/)).toBeNull();
expect(screen.queryByText(/^daemon v/)).toBeNull(); expect(screen.queryByText(/^daemon v/)).toBeNull();
expect(screen.getByTitle("扩展版本").textContent).toBe(`Ext ${EXTENSION_VERSION}`); expect(screen.getByTitle("扩展版本").textContent).toBe(EXTENSION_VERSION);
expect(screen.getByTitle("bsk 版本").textContent).toBe(`CLI ${mockDaemonVersion}`); expect(screen.getByTitle("bsk 版本").textContent).toBe(mockDaemonVersion);
expect(screen.getByText("03c3e47f")).toBeTruthy(); expect(screen.getByText("03c3e47f")).toBeTruthy();
const copyButton = screen.getByRole("button", { name: "复制实例 ID" }); const copyButton = screen.getByRole("button", { name: "复制实例 ID" });
+23 -38
View File
@@ -51,9 +51,7 @@ const { values, positionals } = parseArgs({
}); });
if (values.help) { if (values.help) {
console.log( console.log(readFileSync(new URL(import.meta.url), "utf8").match(/\/\*\*([\s\S]*?)\*\//)?.[1] ?? "");
readFileSync(new URL(import.meta.url), "utf8").match(/\/\*\*([\s\S]*?)\*\//)?.[1] ?? "",
);
process.exit(0); process.exit(0);
} }
@@ -62,7 +60,9 @@ const pushAfter = values.push;
const pushTagsOnly = values["push-tags"]; const pushTagsOnly = values["push-tags"];
const noCommit = values["no-commit"]; const noCommit = values["no-commit"];
const onlyRaw = values.only; const onlyRaw = values.only;
const components = onlyRaw ? onlyRaw.split(",").map((s) => s.trim().toLowerCase()) : ALL_COMPONENTS; const components = onlyRaw
? onlyRaw.split(",").map((s) => s.trim().toLowerCase())
: ALL_COMPONENTS;
for (const c of components) { for (const c of components) {
if (!ALL_COMPONENTS.includes(c)) { if (!ALL_COMPONENTS.includes(c)) {
@@ -95,9 +95,7 @@ if (pushTagsOnly) {
const newVersion = positionals[0]; const newVersion = positionals[0];
if (!newVersion) { if (!newVersion) {
console.error( console.error("Usage: node scripts/release.mjs <version> [--dry-run] [--push] [--only cli,ext,dsh]");
"Usage: node scripts/release.mjs <version> [--dry-run] [--push] [--only cli,ext,dsh]",
);
process.exit(1); process.exit(1);
} }
@@ -112,9 +110,8 @@ if (!/^\d+\.\d+\.\d+(-[\w.]+)?$/.test(newVersion)) {
function readCurrentVersions() { function readCurrentVersions() {
const cargo = readFileSync(VERSION_FILES.cargo, "utf8"); const cargo = readFileSync(VERSION_FILES.cargo, "utf8");
const cargoVer = const cargoVer = cargo.match(/^\[workspace\.package\]\s*\nversion\s*=\s*"([^"]+)"/m)?.[1]
cargo.match(/^\[workspace\.package\]\s*\nversion\s*=\s*"([^"]+)"/m)?.[1] ?? ?? cargo.match(/^version\s*=\s*"([^"]+)"/m)?.[1];
cargo.match(/^version\s*=\s*"([^"]+)"/m)?.[1];
const extPkg = JSON.parse(readFileSync(VERSION_FILES.extension, "utf8")); const extPkg = JSON.parse(readFileSync(VERSION_FILES.extension, "utf8"));
const dshPkg = JSON.parse(readFileSync(VERSION_FILES.dshPlugin, "utf8")); const dshPkg = JSON.parse(readFileSync(VERSION_FILES.dshPlugin, "utf8"));
@@ -173,17 +170,19 @@ function updateChangelog(version) {
} }
const today = new Date().toISOString().slice(0, 10); const today = new Date().toISOString().slice(0, 10);
const escapedVer = version.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); const unreleased = /^## \[Unreleased\]/m;
if (unreleased.test(content)) {
// First: fill in any date-placeholder line for this version (e.g. "## [0.2.0] - 2026-09-XX") content = content.replace(
const versionPlaceholder = new RegExp(`^## \\[${escapedVer}\\]\\s*-\\s*\\d{4}-\\d{2}-XX`, "m"); unreleased,
if (versionPlaceholder.test(content)) { `## [Unreleased]\n\n## [${version}] - ${today}`,
content = content.replace(versionPlaceholder, `## [${version}] - ${today}`); );
} else { } else {
// Otherwise: insert a new section after [Unreleased] const versionPlaceholder = new RegExp(
const unreleased = /^## \[Unreleased\]/m; `^## \\[${version.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\]\\s*-\\s*\\d{4}-\\d{2}-XX`,
if (unreleased.test(content)) { "m",
content = content.replace(unreleased, `## [Unreleased]\n\n## [${version}] - ${today}`); );
if (versionPlaceholder.test(content)) {
content = content.replace(versionPlaceholder, `## [${version}] - ${today}`);
} }
} }
@@ -196,25 +195,13 @@ function updateChangelog(version) {
const writes = [ const writes = [
{ path: VERSION_FILES.cargo, content: bumpCargo(newVersion), label: "Cargo.toml" }, { path: VERSION_FILES.cargo, content: bumpCargo(newVersion), label: "Cargo.toml" },
{ { path: VERSION_FILES.extension, content: bumpPackageJson(VERSION_FILES.extension, newVersion), label: "Extension package.json" },
path: VERSION_FILES.extension, { path: VERSION_FILES.dshPlugin, content: bumpPackageJson(VERSION_FILES.dshPlugin, newVersion), label: "DSH Plugin package.json" },
content: bumpPackageJson(VERSION_FILES.extension, newVersion),
label: "Extension package.json",
},
{
path: VERSION_FILES.dshPlugin,
content: bumpPackageJson(VERSION_FILES.dshPlugin, newVersion),
label: "DSH Plugin package.json",
},
]; ];
const changelogUpdate = updateChangelog(newVersion); const changelogUpdate = updateChangelog(newVersion);
if (changelogUpdate) { if (changelogUpdate) {
writes.push({ writes.push({ path: changelogUpdate.path, content: changelogUpdate.content, label: "CHANGELOG.md" });
path: changelogUpdate.path,
content: changelogUpdate.content,
label: "CHANGELOG.md",
});
} }
for (const w of writes) { for (const w of writes) {
@@ -250,9 +237,7 @@ if (noCommit || dryRun) {
} }
console.log("\nCommitting..."); console.log("\nCommitting...");
run( run("git add Cargo.toml Cargo.lock apps/extension/package.json packages/dsh-plugin-browserskill/package.json CHANGELOG.md 2>/dev/null || true");
"git add Cargo.toml Cargo.lock apps/extension/package.json packages/dsh-plugin-browserskill/package.json CHANGELOG.md 2>/dev/null || true",
);
run(`git commit -m "chore(release): ${newVersion}"`); run(`git commit -m "chore(release): ${newVersion}"`);
console.log("Tagging..."); console.log("Tagging...");