feat(dist,deploy,website): 交付产物统一归集到 releases/<组件>/<版本>,补齐官网与 Linux 验收
三个打包脚本原先各写各的输出目录,现在一律直接落在仓库根 releases/<组件>/<版本>/,分层固定为安装包/免安装/构建中间;dist-win 用 --config.directories.output 覆盖 electron-builder 的目录后再整理,显式传入时不覆盖。插件侧顺手修掉一个既有 bug:原先 rmSync 整个组件目录,重打一次就把上一版的留档抹掉,现在只清当前版本目录。verify-packaged 的 --exe 默认值跟着改到新落点。 deploy/verify-linux.sh 修掉管道在 pipefail 下的 SIGPIPE 误判(命中被算成失败);CI workflow 的出包与上传路径同步;electron-builder.yml 显式指定安装包图标。 website/ 是产品官网(纯静态、无构建步骤,不进 pnpm workspace),含 beUI 动效 token 与实机留档图;客户端冒烟相应加了采集留档图用的外观开关。
This commit is contained in:
1 parent
7b1ae29774
commit
82c85b59c1
40 files changed
+4976
-76
No files matched your search
@@ -10,7 +10,14 @@
|
||||
*
|
||||
* 用法:
|
||||
* node scripts/dist-win.mjs # nsis 安装包 + portable 单文件
|
||||
* node scripts/dist-win.mjs --dir # 仅生成免安装目录 release/win-unpacked
|
||||
* node scripts/dist-win.mjs --dir # 仅生成免安装目录
|
||||
*
|
||||
* 产物统一落到 releases/client/<版本>/(releases/ 不入库,与服务端、插件同级):
|
||||
* 安装包/ 班级小助手-<版本>-x64-setup.exe / -portable.exe(+ .blockmap)
|
||||
* 免安装/ electron-builder 的 win-unpacked 内容
|
||||
* 构建中间/ builder-*.yml、*.nsis.7z
|
||||
* electron-builder 自身的 `directories.output` 由本脚本用 --config 覆盖成上面的版本目录;
|
||||
* 显式传入 `-c.directories.output=...` 时不覆盖,整理(tidyArtifacts)以传入的目录为准。
|
||||
*/
|
||||
import { execFileSync, spawn } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
@@ -59,6 +66,14 @@ if (!fs.existsSync(cli)) {
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
// 交付产物落到 releases/client/<版本>/(与服务端、插件同一约定;releases/ 不入库)
|
||||
const clientVersion = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')).version;
|
||||
const explicitOutput = passthrough.find((item) => item.includes('directories.output'));
|
||||
const destDir = explicitOutput
|
||||
? path.resolve(root, explicitOutput.slice(explicitOutput.indexOf('=') + 1))
|
||||
: path.join(repoRoot, 'releases', 'client', clientVersion);
|
||||
if (!explicitOutput) overrides.push(`--config.directories.output=${destDir}`);
|
||||
|
||||
const cliArgs = [cli, '--win', ...(dirOnly ? ['--dir'] : []), ...overrides, ...passthrough];
|
||||
console.log('[dist] electron-builder', cliArgs.slice(1).join(' '));
|
||||
|
||||
@@ -72,18 +87,18 @@ console.log(`[dist] Node 运行时:${runtime.path}(${runtime.version})`);
|
||||
// 清理上一轮产物:本仓库目录树带沙箱 ACL(含 Everyone 的 DENY(delete child)),
|
||||
// 已存在的产物会被工具(makensis / 7za)判为"Can't open output file / 拒绝访问"而失败,
|
||||
// 手动删掉再打包即可 —— 顺手也保证产物集合确定,不会残留上一轮的旧安装包。
|
||||
const outputDir = path.join(root, 'release');
|
||||
if (fs.existsSync(outputDir)) {
|
||||
for (const name of fs.readdirSync(outputDir)) {
|
||||
if (!/\.(exe|7z|blockmap|yml)$/i.test(name)) continue;
|
||||
try {
|
||||
fs.rmSync(path.join(outputDir, name), { force: true });
|
||||
} catch (error) {
|
||||
console.warn(`[dist] 无法清理旧产物 ${name}:${error.message}`);
|
||||
}
|
||||
let cleaned = false;
|
||||
for (const name of ['win-unpacked', '免安装', '安装包', '构建中间']) {
|
||||
const target = path.join(destDir, name);
|
||||
if (!fs.existsSync(target)) continue;
|
||||
try {
|
||||
fs.rmSync(target, { recursive: true, force: true });
|
||||
cleaned = true;
|
||||
} catch (error) {
|
||||
console.warn(`[dist] 无法清理旧产物 ${name}:${error.message}`);
|
||||
}
|
||||
console.log('[dist] 已清理上一轮的安装包 / 归档');
|
||||
}
|
||||
if (cleaned) console.log('[dist] 已清理上一轮的免安装目录 / 安装包 / 构建中间');
|
||||
|
||||
const child = spawn(runtime.path, cliArgs, { cwd: root, stdio: 'inherit', env });
|
||||
|
||||
@@ -105,21 +120,58 @@ const child = spawn(runtime.path, cliArgs, { cwd: root, stdio: 'inherit', env })
|
||||
function normalizeIntegrityLabel(dir) {
|
||||
if (process.platform !== 'win32') return;
|
||||
const run = (args) => execFileSync('icacls', args, { stdio: 'pipe', windowsHide: true });
|
||||
// 这一行才是"交付物能不能用"的关键,失败必须喊出来
|
||||
try {
|
||||
run([dir, '/setintegritylevel', 'Medium', '/T', '/C']);
|
||||
// 目录自身恢复为"继承父目录的 Low",保证下次构建时 Low 的 7za 仍能写入归档
|
||||
run([dir, '/setintegritylevel', '(OI)(CI)Low']);
|
||||
console.log('[dist] 已修正交付物完整性标签为 Medium,目录恢复继承:', dir);
|
||||
console.log('[dist] 已把交付物完整性标签修正为 Medium:', dir);
|
||||
} catch (error) {
|
||||
console.warn('[dist] 完整性标签修正跳过:', error.message);
|
||||
console.warn('[dist] 完整性标签修正失败(交付物可能装不上,见 AGENTS.md §7 第 7 条):', error.message);
|
||||
}
|
||||
// 目录自身恢复为"继承父目录的 Low",保证下次构建时带 Low 标签的 7za 仍能写进这个目录。
|
||||
// 宿主目录树本来就没有 Low 标签体系时,这一步会被系统拒绝(保持继承即可),属正常,不提示。
|
||||
try {
|
||||
run([dir, '/setintegritylevel', '(OI)(CI)Low']);
|
||||
} catch {
|
||||
/* 忽略 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 把 electron-builder 的原始输出整理成 releases 的固定分层:
|
||||
* win-unpacked/ → 免安装/
|
||||
* *.exe / *.blockmap → 安装包/
|
||||
* *.yml / *.nsis.7z → 构建中间/
|
||||
* electron-builder 每次都会按自己的布局重写这些路径,因此整理只放在打包成功之后做;
|
||||
* 同名文件用 renameSync 同盘移动,不会产生大文件的额外拷贝。
|
||||
*/
|
||||
function tidyArtifacts(dir) {
|
||||
if (!fs.existsSync(dir)) return;
|
||||
const moveInto = (from, sub) => {
|
||||
const to = path.join(dir, sub);
|
||||
fs.mkdirSync(to, { recursive: true });
|
||||
fs.renameSync(from, path.join(to, path.basename(from)));
|
||||
};
|
||||
|
||||
const unpacked = path.join(dir, 'win-unpacked');
|
||||
const portableDir = path.join(dir, '免安装');
|
||||
if (fs.existsSync(unpacked)) {
|
||||
fs.rmSync(portableDir, { recursive: true, force: true });
|
||||
fs.renameSync(unpacked, portableDir);
|
||||
}
|
||||
|
||||
for (const name of fs.readdirSync(dir)) {
|
||||
const from = path.join(dir, name);
|
||||
if (!fs.statSync(from).isFile()) continue;
|
||||
if (/\.(exe|blockmap)$/i.test(name)) moveInto(from, '安装包');
|
||||
else if (/\.(yml|7z)$/i.test(name)) moveInto(from, '构建中间');
|
||||
}
|
||||
}
|
||||
|
||||
child.on('exit', (code) => {
|
||||
if (code === 0) {
|
||||
const output = path.join(root, 'release');
|
||||
normalizeIntegrityLabel(output);
|
||||
console.log('\n[dist] 打包完成,产物目录:', output);
|
||||
tidyArtifacts(destDir);
|
||||
normalizeIntegrityLabel(destDir);
|
||||
console.log('\n[dist] 打包完成,产物目录:', destDir);
|
||||
}
|
||||
process.exit(code ?? 1);
|
||||
});
|
||||
Reference in new issue
Block a user