build(签名流程): 优化签名流程以减少SignPath配额使用,添加相关控制

- 配置electron-builder仅使用SHA256算法签名,避免双签名以减半配额消耗
- 为签名脚本添加配额耗尽处理,超出后跳过后续签名任务
- 新增仅签名主安装包选项和发布工作流签名开关
- 在发布笔记中添加签名状态展示
- 更新自动更新文档,补充SignPath配额问题及解决方案
This commit is contained in:
2026-08-28 03:18:18 +08:00
parent 30451d505c
commit b404ffaef8
6 changed files with 58 additions and 5 deletions
+2
View File
@@ -15,6 +15,7 @@ param(
[Parameter(Mandatory = $true)][string] $BaseVersion,
[Parameter(Mandatory = $true)][string] $FullVersion,
[Parameter(Mandatory = $true)][string] $Mode,
[string] $SigningStatus = "已签名",
[string] $OutputPath = "release-notes.md"
)
@@ -66,6 +67,7 @@ $content = @"
##
$FullVersion
$status
$SigningStatus
##
$commitsSection
+26 -1
View File
@@ -147,11 +147,36 @@ async function downloadWithRetry(downloadUrl, headers) {
/**
* electron-builder 自定义签名入口。
* configuration.path 为待签名文件绝对路径;无 token 时跳过(本地开发构建)。
*
* SIGNPATH_SKIP_ON_QUOTA=true(内部测试用):
* SignPath 年度配额耗尽时跳过签名并继续构建(产物为未签名),
* 首次命中配额错误后记住状态,后续文件不再尝试提交。
* 正式发布请移除该开关并升级 SignPath 套餐。
*/
let quotaExhausted = false;
module.exports = async function signPathSign(configuration) {
if (!process.env.SIGNPATH_API_TOKEN || !process.env.SIGNPATH_ORG_ID) {
console.log(`[signpath-sign] no SignPath credentials, skip signing: ${configuration.name}`);
return;
}
await signWithSignPath(configuration.path);
if (quotaExhausted) {
console.warn(`[signpath-sign] quota exhausted — SKIP signing (UNSIGNED): ${configuration.name}`);
return;
}
// 配额省用模式:只签最终安装包(isNsis=true),跳过内部 exe / 卸载器
if (process.env.SIGNPATH_ONLY_INSTALLER === 'true' && !configuration.isNsis) {
console.log(`[signpath-sign] SIGNPATH_ONLY_INSTALLER, skip inner file: ${configuration.name}`);
return;
}
try {
await signWithSignPath(configuration.path);
} catch (err) {
if (process.env.SIGNPATH_SKIP_ON_QUOTA === 'true' && /quota/i.test(err.message)) {
quotaExhausted = true;
console.warn(`[signpath-sign] SignPath quota exceeded — skip remaining files, artifact will be UNSIGNED: ${err.message}`);
return;
}
throw err;
}
};