9e0cbc7041
Project CI / AI game creator shell Rust shard 2/4 (push) Failing after 18s
Project CI / AI game creator shell Rust shard 4/4 (push) Failing after 18s
Project CI / AI game creator shell Rust shard 1/4 (push) Failing after 18s
Project CI / AI game creator shell Rust shard 3/4 (push) Failing after 18s
Project CI / Backend tests (push) Failing after 18s
Project CI / Native shell tests (push) Failing after 18s
Project CI / AI game creator shell Rust crates (push) Failing after 18s
Project CI / AI game creator shell Rust smoke (push) Failing after 19s
Project CI / Frontend tests (push) Failing after 7s
Project CI / AI game creator shell web tests (push) Failing after 12s
Project CI / Repository checks (push) Failing after 12s
新增 OSS agc/global-version.json 发号模块与发号入口脚本\n构建侧优先采用发号 Job 下发的总号,未传入时本地兜底发号\n渠道高水位降级为回退断言,请求号低于渠道清单版本即失败关闭\n新增 Genarrative-Agc-Global-Version-Issue 发号 Job 与 job config\n调度管线与手动管线先发号再透传 AGC_RELEASE_VERSION\n补充单元测试、生产运维门禁、主规范与里程碑文档
122 lines
3.4 KiB
JavaScript
122 lines
3.4 KiB
JavaScript
/**
|
||
* AGC 总版本号发号入口(CI 发号 Job 与本地手工兜底共用)。
|
||
*
|
||
* 用法:
|
||
* node scripts/issue-global-version.mjs --channel dev-win [--commit <sha>] [--build-id <id>] [--out <file>]
|
||
* node scripts/issue-global-version.mjs --seed-only
|
||
* node scripts/issue-global-version.mjs --dry-run --channel dev-win # 只预览,不写回、不烧号
|
||
*
|
||
* 输出固定为一行 `AGC_GLOBAL_VERSION=<version>`,便于 Jenkins 直接读取。
|
||
*/
|
||
import fs from 'node:fs';
|
||
|
||
import {
|
||
issueGlobalVersion,
|
||
previewNextGlobalVersion,
|
||
readGlobalVersion,
|
||
readReleaseDryRun,
|
||
resolveSeedBaseline,
|
||
writeGlobalVersion,
|
||
} from './agc-global-version.mjs';
|
||
|
||
function parseArgs(argv) {
|
||
const options = {
|
||
channel: '',
|
||
commit: '',
|
||
buildId: '',
|
||
repoVersion: '',
|
||
out: '',
|
||
seedOnly: false,
|
||
dryRun: readReleaseDryRun(),
|
||
};
|
||
for (let index = 0; index < argv.length; index += 1) {
|
||
const arg = argv[index];
|
||
const readValue = (label) => {
|
||
const value = argv[index + 1];
|
||
if (value == null || value.startsWith('--')) {
|
||
throw new Error(`${label} 缺少取值`);
|
||
}
|
||
index += 1;
|
||
return value;
|
||
};
|
||
switch (arg) {
|
||
case '--channel':
|
||
options.channel = readValue('--channel');
|
||
break;
|
||
case '--commit':
|
||
options.commit = readValue('--commit');
|
||
break;
|
||
case '--build-id':
|
||
options.buildId = readValue('--build-id');
|
||
break;
|
||
case '--repo-version':
|
||
options.repoVersion = readValue('--repo-version');
|
||
break;
|
||
case '--out':
|
||
options.out = readValue('--out');
|
||
break;
|
||
case '--seed-only':
|
||
options.seedOnly = true;
|
||
break;
|
||
case '--dry-run':
|
||
options.dryRun = true;
|
||
break;
|
||
default:
|
||
throw new Error(`未知参数:${arg}`);
|
||
}
|
||
}
|
||
return options;
|
||
}
|
||
|
||
function emit(version, options) {
|
||
console.log(`AGC_GLOBAL_VERSION=${version}`);
|
||
if (options.out) {
|
||
fs.writeFileSync(options.out, `${version}\n`, 'utf8');
|
||
}
|
||
}
|
||
|
||
const options = parseArgs(process.argv.slice(2));
|
||
process.env.AGC_RELEASE_DRY_RUN = options.dryRun ? '1' : '0';
|
||
|
||
if (options.seedOnly) {
|
||
const current = await readGlobalVersion();
|
||
if (current) {
|
||
console.log(
|
||
`[agc-global-version] 总号已存在(${current.version}),播种跳过;需要重新播种请先人工确认`,
|
||
);
|
||
emit(current.version, options);
|
||
} else {
|
||
const baseline = await resolveSeedBaseline({
|
||
repoVersion: options.repoVersion || null,
|
||
});
|
||
const payload = {
|
||
version: baseline,
|
||
updatedAt: new Date().toISOString(),
|
||
channel: options.channel || 'seed',
|
||
commit: options.commit || null,
|
||
buildId: options.buildId || null,
|
||
};
|
||
writeGlobalVersion(payload, { dryRun: options.dryRun });
|
||
console.log(
|
||
`[agc-global-version] 播种基线 ${baseline}(尚未发号,首发为下一位)`,
|
||
);
|
||
emit(baseline, options);
|
||
}
|
||
} else if (options.dryRun) {
|
||
const preview = await previewNextGlobalVersion({
|
||
repoVersion: options.repoVersion || null,
|
||
});
|
||
console.log(
|
||
`[agc-global-version] 预览下一个总号 ${preview}(dry-run 不写回、不烧号)`,
|
||
);
|
||
emit(preview, options);
|
||
} else {
|
||
const issued = await issueGlobalVersion({
|
||
channel: options.channel || 'manual',
|
||
commit: options.commit || null,
|
||
buildId: options.buildId || null,
|
||
repoVersion: options.repoVersion || null,
|
||
});
|
||
emit(issued, options);
|
||
}
|