Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@
|---|---|---|
| `MACOS_SIGNING_P12_BASE64` | 签名证书包 | **必须包含私钥!** `base64 < 含私钥的证书.p12` 的结果 |
| `MACOS_SIGNING_P12_PASSWORD` | p12 导出密码 | 导出 p12 时设置的密码 |
| `MACOS_SIGNING_IDENTITY` | 签名身份名称 | `security find-identity -v -p codesigning` 输出的证书 CN,如 `Developer ID Application: ... (TEAMID)` |
| `MACOS_SIGNING_IDENTITY` | 签名身份名称(可选) | `.app` 签名用 `Developer ID Application: ... (TEAMID)`(electron-builder 从 p12 自动发现);pkg 签名自动检测 `Developer ID Installer` 身份,无需填此值 |
| `APPLE_ID` | Apple ID(公证) | notarytool 使用的 Apple ID 邮箱 |
| `MACOS_NOTARY_APP_PASSWORD` | App 专用密码 | Apple ID → 登录与安全 → App 专用密码 |
| `MACOS_NOTARY_TEAM_ID` | Team ID | 开发者账号 Team ID |

## ⚠️ p12 必须包含两种证书(Application + Installer)

**`.app` 签名**需要 **Developer ID Application** 证书;**pkg 签名**(`productsign`)需要 **Developer ID Installer** 证书——两者是独立的证书类型,缺一不可:

- 只有 Application 证书 → `.app` 签名成功,但 `Sign pkg` 步骤报错 `An installer signing identity (not an application signing identity) is required`(实测 #462)
- 两个证书都要在 Apple Developer 后台生成(Certificates → 分别创建两种类型),下载安装到钥匙串后**一并导出**到 p12(`security export -t identities` 会导出全部证书+私钥对)

**检查本机已有哪些身份**:
```bash
security find-identity -v -p codesigning # 列出 Developer ID Application
security find-identity -v # 列出全部(含 Developer ID Installer)
```

## ⚠️ p12 必须包含私钥(v0.2.7 四次构建失败的教训)

**现象**:`Import signing certificate` 步骤报 `SecItemCopyMatching: The specified item could not be found in the keychain`(早期)或 CI 明确报错 `MACOS_SIGNING_P12_BASE64 未包含可签名私钥`(#456 后)。
Expand All @@ -33,9 +46,9 @@
# 用证书 CN 查询准确名称(本机已有有效 identity,无需重新申请证书)
security find-identity -v -p codesigning
# 导出含私钥 p12(会提示输入钥匙串密码 + 设置导出密码)
# ⚠️ 不指定证书名称 = 导出全部身份(Application + Installer 一并包含)
security export -k ~/Library/Keychains/login.keychain-db -t identities -f pkcs12 \
-P '新导出密码' -o ~/Downloads/emrg-cert/signing-with-key.p12 \
"Developer ID Application: <你的名字> (Y55RQ6LU24)"
-P '新导出密码' -o ~/Downloads/emrg-cert/signing-with-key.p12
# 用导出的 p12 更新 MACOS_SIGNING_P12_BASE64 和 MACOS_SIGNING_P12_PASSWORD(导出密码)
```

Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,22 @@ jobs:
run: bash packaging/make-installer.sh

# ── pkg 签名(macOS only,P2;Secret 未配则跳过降级)──
# ⚠️ productsign 需要 Developer ID Installer 身份(非 Application 身份)——
# 实测 #462:MACOS_SIGNING_IDENTITY 配 Application 身份报
# "An installer signing identity (not an application signing identity) is required"。
# 从 p12 自动检测 Installer 身份,缺失则明确报错指引宿主补证书。
- name: Sign pkg (macOS only)
if: runner.os == 'macOS' && env.MACOS_SIGNING_IDENTITY != ''
if: runner.os == 'macOS' && env.MACOS_SIGNING_P12_BASE64 != ''
shell: bash
run: |
PKG="$(find dist/artifacts -maxdepth 1 -name 'EMRG-*-macos-*.pkg' | head -1)"
if [ -z "$PKG" ]; then echo "no pkg found, skipping"; exit 0; fi
productsign --sign "$MACOS_SIGNING_IDENTITY" "$PKG" "${PKG}.signed"
INSTALLER_ID="$(security find-identity -v /tmp/ci.keychain | grep 'Developer ID Installer' | head -1 | sed -E 's/.*"([^"]+)".*/\1/')"
if [ -z "$INSTALLER_ID" ]; then
echo "::error::pkg 签名需要 Developer ID Installer 证书(productsign 不接受 Application 身份)。请在 Apple Developer 后台生成 Developer ID Installer 证书,下载导入钥匙串后随 p12 一并导出(security export -t identities 含全部证书+私钥),更新 MACOS_SIGNING_P12_BASE64。"
exit 1
fi
productsign --sign "$INSTALLER_ID" "$PKG" "${PKG}.signed"
mv "${PKG}.signed" "$PKG"
# P3 验证:证书存在时签名必须成功(rant 验收:pkgutil 显示 signed by Developer ID)
pkgutil --check-signature "$PKG"
Expand Down
1 change: 0 additions & 1 deletion emrg/gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
],
"icon": "../packaging/assets/",
"mac": {
"identity": null,
"hardenedRuntime": true,
"target": [
{
Expand Down
Loading