feat: add build-only mac release option

This commit is contained in:
江林铖 2026-09-09 18:22:02 +08:00
parent 754c5e05ed
commit 7563cf573e
2 changed files with 12 additions and 1 deletions

View File

@ -38,6 +38,7 @@ const USAGE = `gongxiangp2 Mac 部署入口
--dry-run 仅执行源码、SSH、Registry 与生产连通性预检
--no-cache 不使用 Docker 构建缓存
--reuse-verified-image 复用已经校验的精确提交镜像
--skip-deploy 仅构建并推送精确提交镜像,不连接生产机或切换流量
--keep-old-images 不清理旧 Docker 镜像
--aggressive-cache-cleanup 清理超过 7 天的构建缓存
--no-rollback 禁用失败后的旧镜像自动恢复
@ -67,6 +68,7 @@ export function parseArguments(argv) {
dryRun: false,
noCache: false,
reuseVerifiedImage: false,
skipDeploy: false,
keepOldImages: false,
aggressiveCleanup: false,
noRollback: false,
@ -85,6 +87,7 @@ export function parseArguments(argv) {
case '--dry-run': options.dryRun = true; break
case '--no-cache': options.noCache = true; break
case '--reuse-verified-image': options.reuseVerifiedImage = true; break
case '--skip-deploy': options.skipDeploy = true; break
case '--keep-old-images': options.keepOldImages = true; break
case '--aggressive-cache-cleanup': options.aggressiveCleanup = true; break
case '--no-rollback': options.noRollback = true; break
@ -101,6 +104,9 @@ export function parseArguments(argv) {
if (options.reuseVerifiedImage && options.noCache) {
throw new Error('--reuse-verified-image 不能与 --no-cache 同时使用')
}
if (options.reuseVerifiedImage && options.skipDeploy) {
throw new Error('--reuse-verified-image 不能与 --skip-deploy 同时使用')
}
return options
}
@ -358,7 +364,7 @@ async function main() {
__SKIP_BUILD__: '0',
__SKIP_PUSH__: '0',
__REUSE_VERIFIED_IMAGE__: options.reuseVerifiedImage ? '1' : '0',
__SKIP_DEPLOY__: '0',
__SKIP_DEPLOY__: options.skipDeploy ? '1' : '0',
__KEEP_OLD_IMAGES__: options.keepOldImages ? '1' : '0',
__AGGRESSIVE_CLEANUP__: options.aggressiveCleanup ? '1' : '0',
__ROLLBACK_ON_FAILURE__: options.noRollback ? '0' : '1',

View File

@ -39,6 +39,11 @@ test('Mac entry requires an exact commit outside DryRun', () => {
assert.throws(() => parseArguments(['--commit', 'abc']), /40 位小写/)
assert.equal(parseArguments(['--dry-run']).dryRun, true)
assert.equal(parseArguments(['--commit', 'b'.repeat(40)]).commit, 'b'.repeat(40))
assert.equal(parseArguments(['--commit', 'b'.repeat(40), '--skip-deploy']).skipDeploy, true)
assert.throws(
() => parseArguments(['--commit', 'b'.repeat(40), '--reuse-verified-image', '--skip-deploy']),
/不能与 --skip-deploy/,
)
})
test('deployment SSH hops keep long builds and cutovers alive', () => {