Files
gstack/scripts/detect-bump.ts
Rocky 834c6db075
Some checks failed
Workflow Lint / actionlint (push) Has been cancelled
Build CI Image / build (push) Has been cancelled
Skill Docs Freshness / check-freshness (push) Has been cancelled
Periodic Evals / build-image (push) Has been cancelled
Periodic Evals / evals (map[file:test/codex-e2e.test.ts name:e2e-codex]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/gemini-e2e.test.ts name:e2e-gemini]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-e2e-design.test.ts name:e2e-design]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-e2e-plan.test.ts name:e2e-plan]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-e2e-qa-bugs.test.ts name:e2e-qa-bugs]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-e2e-qa-workflow.test.ts name:e2e-qa-workflow]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-e2e-review.test.ts name:e2e-review]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-e2e-workflow.test.ts name:e2e-workflow]) (push) Has been cancelled
Periodic Evals / evals (map[file:test/skill-routing-e2e.test.ts name:e2e-routing]) (push) Has been cancelled
Initial import from garrytan/gstack@026751e (main snapshot via local relay)
Source: https://github.com/garrytan/gstack/commit/026751e
2026-05-19 21:18:17 +02:00

32 lines
1.2 KiB
TypeScript

#!/usr/bin/env bun
// detect-bump — crude heuristic for picking a bump level from a VERSION pair.
// Used by CI's version-gate job to re-run the util with the "same" level that
// /ship used, without needing persisted bump-intent.
//
// Input: two VERSION strings via argv: current (base) and target (branch).
// Output: a single word: major|minor|patch|micro
//
// Heuristic: compare slot-by-slot. The first slot that differs IS the level.
// If nothing differs (shouldn't happen when called by CI gate — the whole point
// is the branch bumped VERSION), default to "patch".
function detect(a: string, b: string): string {
const pa = a.trim().match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
const pb = b.trim().match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
if (!pa || !pb) return "patch";
const [, a1, a2, a3, a4] = pa;
const [, b1, b2, b3, b4] = pb;
if (a1 !== b1) return "major";
if (a2 !== b2) return "minor";
if (a3 !== b3) return "patch";
if (a4 !== b4) return "micro";
return "patch";
}
const [, , base, target] = process.argv;
if (!base || !target) {
console.error("Usage: detect-bump <base-version> <branch-version>");
process.exit(2);
}
console.log(detect(base, target));