From 86d659cf40a9b202c66349dfdb496d77e83e96d5 Mon Sep 17 00:00:00 2001 From: Christ Date: Tue, 11 Aug 2026 21:35:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=81=BF=E5=85=8D=20macOS=20=E7=AD=BE?= =?UTF-8?q?=E5=90=8D=E5=AF=BC=E5=85=A5=E8=A7=A6=E5=8F=91=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用临时钥匙串和 -A 授权导入签名身份,移除会触发用户交互的分区列表配置。 通过 GitHub macOS runner 的免密码 sudo 写入 codeSign 与 pkgSign 管理员信任设置。 保留临时钥匙串搜索列表,确保 codesign 和 productsign 可以找到应用及安装包签名身份。 --- .github/workflows/desktop-cd.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/desktop-cd.yml b/.github/workflows/desktop-cd.yml index f2d4d8a..5b6a61a 100644 --- a/.github/workflows/desktop-cd.yml +++ b/.github/workflows/desktop-cd.yml @@ -215,14 +215,16 @@ jobs: printf '%s' "$MACOS_SIGNING_P12_BASE64" | base64 --decode > "$app_p12_path" printf '%s' "$MACOS_INSTALLER_SIGNING_P12_BASE64" | base64 --decode > "$installer_p12_path" security create-keychain -p "$keychain_password" "$keychain_path" + security set-keychain-settings -lut 21600 "$keychain_path" security unlock-keychain -p "$keychain_password" "$keychain_path" - security import "$app_p12_path" -k "$keychain_path" -P "$MACOS_SIGNING_P12_PASSWORD" -T /usr/bin/codesign - security import "$installer_p12_path" -k "$keychain_path" -P "$MACOS_SIGNING_P12_PASSWORD" -T /usr/bin/productsign + # 临时 CI 钥匙串使用 -A 授权签名工具,避免 set-key-partition-list 触发交互确认。 + security import "$app_p12_path" -k "$keychain_path" -P "$MACOS_SIGNING_P12_PASSWORD" -A + security import "$installer_p12_path" -k "$keychain_path" -P "$MACOS_SIGNING_P12_PASSWORD" -A security find-certificate -c "$MACOS_SIGNING_IDENTITY" -p "$keychain_path" > "$app_cert_path" security find-certificate -c "$MACOS_INSTALLER_SIGNING_IDENTITY" -p "$keychain_path" > "$installer_cert_path" - security add-trusted-cert -d -r trustRoot -p codeSign -k "$keychain_path" "$app_cert_path" - security add-trusted-cert -d -r trustRoot -p basic -k "$keychain_path" "$installer_cert_path" - security set-key-partition-list -S apple-tool:,apple: -s -k "$keychain_password" "$keychain_path" + # GitHub macOS hosted runner 提供免密码 sudo;用 admin Trust Settings 避免弹认证对话框。 + sudo -n security add-trusted-cert -d -r trustRoot -p codeSign -k "$keychain_path" "$app_cert_path" + sudo -n security add-trusted-cert -d -r trustRoot -p pkgSign -k "$keychain_path" "$installer_cert_path" security list-keychains -d user -s "$keychain_path" security unlock-keychain -p "$keychain_password" "$keychain_path" echo "MACOS_SIGNING_KEYCHAIN=$keychain_path" >> "$GITHUB_ENV"