diff --git a/.gitignore b/.gitignore index 7cdbe04..a8a730a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ config/auth.json config/model.json config/codex.json CLAUDE.md +dist-exe/* +!dist-exe/*.tar.gz diff --git a/dist-exe/cc-web-bun-linux-x64-baseline.tar.gz b/dist-exe/cc-web-bun-linux-x64-baseline.tar.gz new file mode 100644 index 0000000..116e675 Binary files /dev/null and b/dist-exe/cc-web-bun-linux-x64-baseline.tar.gz differ diff --git a/scripts/build-single-exe.js b/scripts/build-single-exe.js index ee4ce99..a542967 100644 --- a/scripts/build-single-exe.js +++ b/scripts/build-single-exe.js @@ -64,7 +64,8 @@ function printHelp() { 说明: 默认 target 是 ${DEFAULT_TARGET},用于兼容 CentOS 7 这类老 glibc Linux x64 系统。 - 该命令只打包 cc-web 服务本体;Claude/Codex CLI 仍在运行时从宿主机 PATH 或 CLAUDE_PATH/CODEX_PATH 调用。`); + 该命令只打包 cc-web 服务本体;Claude/Codex CLI 仍在运行时从宿主机 PATH 或 CLAUDE_PATH/CODEX_PATH 调用。 + 构建完成后会同时生成 dist-exe// 和 dist-exe/cc-web-.tar.gz。`); } function isWindowsTarget(target) { @@ -170,6 +171,22 @@ function runBunBuild(projectRoot, target, outfile) { } } +function createArchive(outdir, target, name) { + const archivePath = path.join(outdir, `${name}-${target}.tar.gz`); + fs.rmSync(archivePath, { force: true }); + const result = spawnSync('tar', ['-C', outdir, '-czf', archivePath, target], { + stdio: 'inherit', + }); + if (result.error && result.error.code === 'ENOENT') { + throw new Error('未找到 tar,无法生成发布压缩包。'); + } + if (result.error) throw result.error; + if (result.status !== 0) { + throw new Error(`生成发布压缩包失败,退出码: ${result.status}`); + } + return archivePath; +} + function main() { const options = parseArgs(process.argv.slice(2)); if (options.help) { @@ -190,9 +207,11 @@ function main() { runBunBuild(projectRoot, target, outfile); if (!isWindowsTarget(target)) fs.chmodSync(outfile, 0o755); copyRuntimeAssets(projectRoot, releaseDir, target, binaryName); + const archivePath = createArchive(outdir, target, options.name || DEFAULT_NAME); console.log(`[build:single-exe] 发布目录: ${releaseDir}`); console.log(`[build:single-exe] 可执行文件: ${outfile}`); + console.log(`[build:single-exe] 发布压缩包: ${archivePath}`); } try {