From 77e9134c3034f9b33ca3fdf71a678a2c7d0d0922 Mon Sep 17 00:00:00 2001 From: argszero Date: Thu, 6 Aug 2026 13:39:51 +0800 Subject: [PATCH] =?UTF-8?q?emrg:=20pkg=20=E7=AD=BE=E5=90=8D=E8=A1=A5=20Imp?= =?UTF-8?q?ort=20step=20=E6=97=A9=E6=A3=80=20=E2=80=94=20find-certificate?= =?UTF-8?q?=20=E6=A0=A1=E9=AA=8C=20Developer=20ID=20Installer=20=E8=AF=81?= =?UTF-8?q?=E4=B9=A6=EF=BC=88=E8=BE=93=E5=87=BA=E5=88=A4=E7=A9=BA=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #462 合并时并行实例采用了旧 head(3abcf78),本补丁补充被遗漏的早检改进: 在 Import step 私钥校验后校验 p12 是否含 Developer ID Installer 证书,缺失即 明确报错(早于 Sign pkg 失败,反馈更快)。 ⚠️ 三态实测(#455 教训):find-certificate 无匹配证书时返回 exit 0, 必须用 $(...) 输出判空而非 ! 退出码判断: - 空 keychain(无 Installer)→ 判空 → 报错 ✅ - 含 Installer 证书 → 非空 → 通过 ✅ --- .github/workflows/build-release.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 75e801f..3330ea9 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -80,6 +80,18 @@ jobs: echo "::error::MACOS_SIGNING_P12_BASE64 未包含可签名私钥(security import 仅导入证书链)。请从 Keychain Access 导出含私钥的 p12(证书右键 → 导出 → 勾选\"包含私钥\"),重新 base64 后更新 GitHub Secret。import 输出:${IMPORT_OUTPUT}" exit 1 fi + # pkg 签名证书存在性校验(v0.2.7 第 7 次构建根因:p12 只有 Developer ID + # Application 证书——签 .app 成功,但 productsign 签 pkg 需要独立的 + # Developer ID Installer 证书,缺失报 "An installer signing identity (not + # an application signing identity) is required" 的 cryptic 错误)。 + # 两种证书在 developer.apple.com → Certificates 分别创建,导出 p12 时 + # 需同时勾选(或分别导出后合并)。find-certificate 不受 policy 限制。 + # ⚠️ 必须用输出判空而非退出码:实测 find-certificate 无匹配证书时 + # 也返回 exit 0(正反两态验证,#455 教训)。 + if [ -z "$(security find-certificate -c 'Developer ID Installer' -a /tmp/ci.keychain 2>/dev/null)" ]; then + echo "::error::MACOS_SIGNING_P12_BASE64 缺少 Developer ID Installer 证书(pkg 签名必需)。Developer ID Application 只能签 .app,productsign 签 pkg 需要独立的 Developer ID Installer 证书。请在 developer.apple.com → Certificates 创建 Developer ID Installer(与 Application 是两张不同证书),连同私钥一起导出 p12 后更新 GitHub Secret。" + exit 1 + fi # set-key-partition-list 与 electron-builder macCodeSign.js 完全一致: # security set-key-partition-list -S apple-tool:,apple: -s -k # -s = Match keys that can sign(必须显式提供才能定位私钥项目);