From 92189cc05e07ef9f265de54f1bc9039bd74a228f Mon Sep 17 00:00:00 2001 From: yunyingk Date: Tue, 25 Aug 2026 16:06:09 +0800 Subject: [PATCH] Add bun run bump automated version synchronization script and update guidelines --- AGENTS.md | 5 +-- README.md | 6 ++-- dist/mcp/server.js | 1 + package.json | 1 + scripts/bump-version.ts | 72 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 scripts/bump-version.ts diff --git a/AGENTS.md b/AGENTS.md index 255676c..0102f4b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -17,6 +17,7 @@ Tests are colocated as `*.test.ts` files in `src/`. OpenAPI source YAML lives in - `bun run probe -- `: run the local connectivity/config probe. - `bun run check`: type-check with `tsc --noEmit`. - `bun test`: run all colocated Bun tests. +- `bun run bump `: bump version across all manifest/skill/openapi files and bundle. - `bun run openapi:bundle`: rebuild `dist/openapi.json`. - `bun run build:binary`: compile the standalone `seal-home` binary to `dist/bin/seal-home` (gitignored). - `bun run build:plugin`: bundle the MCP server to `dist/mcp/server.js` (tracked, used by `.mcp.json`). @@ -38,9 +39,9 @@ Recent commits use concise imperative subjects, often `Add ...` or `Refine ...`, ## Release & Publishing Guidelines 1. **Version Bump Checklist**: - - Update version string in `package.json`, `.zcode-plugin/plugin.json`, `skills/seal-home/SKILL.md`, and `openapi/openapi.yaml`. + - Run `bun run bump ` (automatically updates `package.json`, `.zcode-plugin/plugin.json`, `skills/seal-home/SKILL.md`, `openapi/openapi.yaml`, and bundles `dist/`). - Update `CHANGELOG.md` with new features and fixes. - - Run `bun run openapi:bundle && bun run build:plugin && bun test && bun run check`. + - Run `bun test && bun run check`. 2. **Tag & Release**: - Create an annotated Git tag with a descriptive release summary: ```bash diff --git a/README.md b/README.md index d3f13cc..56cb104 100644 --- a/README.md +++ b/README.md @@ -294,11 +294,11 @@ When `_langfuseTraceId` exists, downstream tools should fetch the trace directly To release a new version of `seal-home`: 1. **Version Bump Checklist**: - - Bump version across `package.json`, `.zcode-plugin/plugin.json`, `skills/seal-home/SKILL.md`, and `openapi/openapi.yaml`. + - Run `bun run bump ` (automatically updates `package.json`, `.zcode-plugin/plugin.json`, `skills/seal-home/SKILL.md`, `openapi/openapi.yaml`, and bundles `dist/`). - Update `CHANGELOG.md` with release notes and highlights. - - Run verification and bundles: + - Run verification tests: ```bash - bun run openapi:bundle && bun run build:plugin && bun test && bun run check + bun test && bun run check ``` 2. **Tag & Publish**: - Commit changes and create an annotated Git tag with release notes: diff --git a/dist/mcp/server.js b/dist/mcp/server.js index 91282bd..13ce188 100644 --- a/dist/mcp/server.js +++ b/dist/mcp/server.js @@ -24957,6 +24957,7 @@ var package_default = { check: "tsc --noEmit", "build:binary": "node scripts/build-binary.mjs", "build:plugin": "node scripts/build-plugin.mjs", + bump: "bun run scripts/bump-version.ts", "openapi:bundle": "bun run scripts/bundle-openapi.ts", test: "bun test" }, diff --git a/package.json b/package.json index 4a2a72e..bb960f6 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "check": "tsc --noEmit", "build:binary": "node scripts/build-binary.mjs", "build:plugin": "node scripts/build-plugin.mjs", + "bump": "bun run scripts/bump-version.ts", "openapi:bundle": "bun run scripts/bundle-openapi.ts", "test": "bun test" }, diff --git a/scripts/bump-version.ts b/scripts/bump-version.ts new file mode 100644 index 0000000..b95bce2 --- /dev/null +++ b/scripts/bump-version.ts @@ -0,0 +1,72 @@ +#!/usr/bin/env bun +import { readFileSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; +import { execSync } from "node:child_process"; + +const ROOT = join(import.meta.dirname, ".."); +const pkgPath = join(ROOT, "package.json"); +const pkg = JSON.parse(readFileSync(pkgPath, "utf-8")); +const currentVersion: string = pkg.version; + +const input = process.argv[2]?.trim(); +if (!input) { + console.error("Usage: bun run bump "); + console.error(`Current version: ${currentVersion}`); + process.exit(1); +} + +let nextVersion = input.replace(/^v/, ""); +if (input === "patch" || input === "minor" || input === "major") { + const [major, minor, patch] = currentVersion.split(".").map(Number); + if (input === "patch") nextVersion = `${major}.${minor}.${patch + 1}`; + if (input === "minor") nextVersion = `${major}.${minor + 1}.0`; + if (input === "major") nextVersion = `${major + 1}.0.0`; +} + +if (!/^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?$/.test(nextVersion)) { + console.error(`Invalid SemVer format: '${nextVersion}'`); + process.exit(1); +} + +console.log(`==> Bumping version: ${currentVersion} -> ${nextVersion}`); + +// 1. package.json +pkg.version = nextVersion; +writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n"); +console.log("āœ“ Updated package.json"); + +// 2. .zcode-plugin/plugin.json +const pluginPath = join(ROOT, ".zcode-plugin", "plugin.json"); +const plugin = JSON.parse(readFileSync(pluginPath, "utf-8")); +plugin.version = nextVersion; +writeFileSync(pluginPath, JSON.stringify(plugin, null, 2) + "\n"); +console.log("āœ“ Updated .zcode-plugin/plugin.json"); + +// 3. skills/seal-home/SKILL.md +const skillPath = join(ROOT, "skills", "seal-home", "SKILL.md"); +let skillContent = readFileSync(skillPath, "utf-8"); +skillContent = skillContent.replace(/description: "v[\d.]+: /g, `description: "v${nextVersion}: `); +skillContent = skillContent.replace(/version: [\d.]+/g, `version: ${nextVersion}`); +skillContent = skillContent.replace(/# Seal Home \(v[\d.]+\)/g, `# Seal Home (v${nextVersion})`); +skillContent = skillContent.replace(/\(v[\d.]+\)/g, `(v${nextVersion})`); +writeFileSync(skillPath, skillContent); +console.log("āœ“ Updated skills/seal-home/SKILL.md"); + +// 4. openapi/openapi.yaml +const openapiPath = join(ROOT, "openapi", "openapi.yaml"); +let openapiContent = readFileSync(openapiPath, "utf-8"); +openapiContent = openapiContent.replace(/version: [\d.]+/g, `version: ${nextVersion}`); +writeFileSync(openapiPath, openapiContent); +console.log("āœ“ Updated openapi/openapi.yaml"); + +// 5. Rebuild bundles +console.log("==> Rebuilding OpenAPI and plugin bundles..."); +execSync("bun run openapi:bundle", { cwd: ROOT, stdio: "inherit" }); +execSync("bun run build:plugin", { cwd: ROOT, stdio: "inherit" }); + +console.log("\nšŸŽ‰ Successfully bumped version to " + nextVersion + "!"); +console.log("\nNext steps to publish:"); +console.log(` 1. Update CHANGELOG.md`); +console.log(` 2. git commit -am "Release v${nextVersion}: "`); +console.log(` 3. git tag -a v${nextVersion} -m "šŸš€ "`); +console.log(` 4. git push origin master --tags && git push home master --tags\n`);