feat(release): auto-number candidates built from feature/motion

This commit is contained in:
罗高
2026-11-10 19:53:54 +08:00
parent fd687a6a3d
commit a664ffeb82
12 changed files with 119 additions and 46 deletions

View File

@@ -1,5 +1,12 @@
import assert from 'node:assert/strict';
export function testVersion(base, run, attempt = '1') {
assert(/^\d+\.\d+\.\d+$/.test(base), 'Source version must be MAJOR.MINOR.PATCH');
assert(/^[1-9]\d*$/.test(String(run)) && /^[1-9]\d*$/.test(String(attempt)), 'Use positive run and attempt numbers');
const [major, minor, patch] = base.split('.').map(Number);
return `${major}.${minor}.${patch + 1}-test.${run}.${attempt}`;
}
export function checkReleaseVersion(version) {
assert.match(version, /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-test\.[1-9]\d*(?:\.[1-9]\d*)*)?$/, 'Use MAJOR.MINOR.PATCH or MAJOR.MINOR.PATCH-test.N[.N]');
}

View File

@@ -8,8 +8,8 @@ import { spawn } from 'node:child_process';
import { releaseProfile } from '../shared/mcp-registry.ts';
import { distributionFiles } from './distribution.ts';
import { packageTemplateConfig } from '../shared/template-config.ts';
import { checkReleaseVersion } from './release-version.mjs';
export { checkReleaseVersion } from './release-version.mjs';
import { checkReleaseVersion, testVersion } from './release-version.mjs';
export { checkReleaseVersion, testVersion } from './release-version.mjs';
export const root = fileURLToPath(new URL('../', import.meta.url));
// Git Bash tar interprets C: as a remote host; use Windows' native archive tool.
@@ -20,12 +20,6 @@ export function targetInfo(target) {
assert(info, `Unsupported target: ${target}`);
return info;
}
export function testVersion(base, run, attempt = '1') {
assert(/^\d+\.\d+\.\d+$/.test(base), 'Source version must be MAJOR.MINOR.PATCH');
assert(/^[1-9]\d*$/.test(String(run)) && /^[1-9]\d*$/.test(String(attempt)), 'Use positive run and attempt numbers');
const [major, minor, patch] = base.split('.').map(Number);
return `${major}.${minor}.${patch + 1}-test.${run}.${attempt}`;
}
export async function run(command, args, options = {}) {
await new Promise((resolve, reject) => {
const child = spawn(command, args, { cwd: root, stdio: 'inherit', windowsHide: true, ...options });