Răsfoiți Sursa

支持使用钥匙串凭据公证桌面更新包

Samien 1 lună în urmă
părinte
comite
3139105449

+ 3 - 0
desktop/release-artifacts.test.mjs

@@ -14,6 +14,9 @@ test('formal desktop releases require a distribution identity and notarization c
   const options = releaseSigningOptions({ CSC_NAME: 'Developer ID Application: Test', APPLE_API_KEY: '/fixture/key.p8', APPLE_API_KEY_ID: 'key', APPLE_API_ISSUER: 'issuer' })
   assert.equal(options.forceCodeSigning, true); assert.equal(options.mac.notarize, true)
   assert.equal(options.mac.identity, 'Test'); assert.equal(options.mac.type, 'distribution')
+  assert.deepEqual(releaseSigningOptions({ CSC_NAME: 'Developer ID Application: Test', APPLE_KEYCHAIN_PROFILE: 'yaoyao-notary' }), options)
+  assert.throws(() => releaseSigningOptions({ CSC_NAME: 'Developer ID Application: Test', APPLE_KEYCHAIN: '/fixture/login.keychain-db' }), /公证/)
+  assert.throws(() => releaseSigningOptions({ CSC_NAME: 'Developer ID Application: Test', APPLE_KEYCHAIN_PROFILE: '  ' }), /公证/)
 })
 
 test('release verification rejects incomplete, mixed-version and corrupt updater artifacts', async () => {

+ 2 - 1
docs/release-process.md

@@ -20,7 +20,8 @@
 `npm run desktop:pack` 用于本地打包;发布支持自动升级的正式分发包时使用 `npm run desktop:release`,其上传行为固定为 `never`,先生成可检查的本地产物。需要:
 
 - `CSC_NAME` 指定 `Developer ID Application: ...` 分发签名身份。
-- 配置 `APPLE_API_KEY`、`APPLE_API_KEY_ID`、`APPLE_API_ISSUER`,或 `APPLE_ID`、`APPLE_APP_SPECIFIC_PASSWORD`、`APPLE_TEAM_ID` 供公证使用。凭据通过环境注入,不写入仓库或发布说明。
+- 公证优先使用本机钥匙串:运行 `xcrun notarytool store-credentials yaoyao-notary --apple-id <邮箱> --team-id <团队 ID>`,按隐藏输入提示录入 App 专用密码,验证通过后设置 `APPLE_KEYCHAIN_PROFILE=yaoyao-notary`。自定义钥匙串可另设 `APPLE_KEYCHAIN` 路径。
+- 也支持配置 `APPLE_API_KEY`、`APPLE_API_KEY_ID`、`APPLE_API_ISSUER`,或 `APPLE_ID`、`APPLE_APP_SPECIFIC_PASSWORD`、`APPLE_TEAM_ID`。凭据通过钥匙串或环境注入,不写入仓库或发布说明。
 
 正式命令启用强制签名与公证,并校验包内 `app-update.yml` 指向 `Lsamien/yaoyao`、签名完整性、公证票据,以及 `latest-mac.yml` 的版本、附件名、大小和 SHA-512。当前仍只发布 Apple Silicon 桌面包;不要上传指向不存在的 Intel 包的清单。
 

+ 2 - 1
scripts/desktop-release.mjs

@@ -11,7 +11,8 @@ export function releaseSigningOptions(env = process.env) {
     throw new Error('正式自动更新包需要 CSC_NAME 指定 Developer ID Application 签名身份')
   const apiKey = env.APPLE_API_KEY && env.APPLE_API_KEY_ID && env.APPLE_API_ISSUER
   const appleId = env.APPLE_ID && env.APPLE_APP_SPECIFIC_PASSWORD && env.APPLE_TEAM_ID
-  if (!apiKey && !appleId) throw new Error('请配置 Apple 公证凭据:APPLE_API_KEY/APPLE_API_KEY_ID/APPLE_API_ISSUER,或 APPLE_ID/APPLE_APP_SPECIFIC_PASSWORD/APPLE_TEAM_ID')
+  const keychainProfile = env.APPLE_KEYCHAIN_PROFILE?.trim()
+  if (!apiKey && !appleId && !keychainProfile) throw new Error('请配置 Apple 公证凭据:APPLE_KEYCHAIN_PROFILE,APPLE_API_KEY/APPLE_API_KEY_ID/APPLE_API_ISSUER,或 APPLE_ID/APPLE_APP_SPECIFIC_PASSWORD/APPLE_TEAM_ID')
   // electron-builder selects the certificate type itself and rejects its prefix
   // in the identity qualifier. Enforce a distribution identity, then strip it.
   const identity = env.CSC_NAME.slice('Developer ID Application:'.length).trim()