fix: 修复 macOS Chromium 签名与缓存保存

- 对 Chromium 内嵌的 Helper App、Framework 和外层应用执行递归签名,并改用临时清单传递路径,保留真实签名错误。

- 将 macOS Playwright runtime 缓存拆分为恢复和保存步骤,在 runtime 下载完成后立即写入缓存,并增加前缀回退键。
This commit is contained in:
Christ committed 2026-08-12 01:46:50 +08:00
1 parent 0bafa50dbf
commit fed5d582e7
2 files changed
+33 -11

No files matched your search

+12 -1
View File
@@ -215,12 +215,14 @@ jobs:
- name: 缓存 macOS Chromium runtime
id: cache-macos-playwright
uses: actions/cache@v6
uses: actions/cache/restore@v6
with:
path: |
dist/macos/playwright-runtime/arm64
dist/macos/playwright-runtime/amd64
key: ydisks-playwright-runtime-v1-macos-universal-${{ hashFiles('go.mod') }}
restore-keys: |
ydisks-playwright-runtime-v1-macos-universal-
- name: 预下载 macOS Chromium runtime
if: steps.cache-macos-playwright.outputs.cache-hit != 'true'
@@ -239,6 +241,15 @@ jobs:
-driver-dir "$PWD/dist/macos/playwright-runtime/amd64/playwright-driver" \
-browser-dir "$PWD/dist/macos/playwright-runtime/amd64/playwright-browsers"
- name: 保存 macOS Chromium runtime 缓存
if: steps.cache-macos-playwright.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: |
dist/macos/playwright-runtime/arm64
dist/macos/playwright-runtime/amd64
key: ${{ steps.cache-macos-playwright.outputs.cache-primary-key }}
- name: 导入 macOS 签名证书
env:
MACOS_SIGNING_P12_BASE64: ${{ secrets.MACOS_SIGNING_P12_BASE64 }}
+21 -10
View File
@@ -57,25 +57,36 @@ if [ -n "${MACOS_SIGNING_IDENTITY:-}" ]; then
sign_nested_bundle() {
nested_bundle="$1"
echo "Signing nested bundle: $nested_bundle"
sign_code "$nested_bundle"
if [ -n "${MACOS_SIGNING_KEYCHAIN:-}" ]; then
codesign --force --deep --sign "$MACOS_SIGNING_IDENTITY" \
--keychain "$MACOS_SIGNING_KEYCHAIN" --timestamp=none "$nested_bundle"
else
codesign --force --deep --sign "$MACOS_SIGNING_IDENTITY" \
--timestamp=none "$nested_bundle"
fi
}
# Playwright runtime 中包含 Node 和 Chromium.app,必须在 App 签名之前完成签名。
# 先签每个 Mach-O 文件,再按目录深度从内到外签 bundle。Chromium 的
# .app 内还嵌套了 .framework/.xpc 和其他 helper .app;依赖 codesign --deep
# 自动推断顺序会在 amd64 runner 上留下未签名的 framework 主程序。
find "$APP/Contents/Resources/playwright-runtime" -type f -print | while IFS= read -r executable; do
# .app 内还嵌套了 .framework/.xpc 和其他 helper .app;必须先签 Mach-O,
# 再按目录深度对每个 bundle 递归签名,最后才签外层应用。
signing_list="$(mktemp)"
trap 'rm -f "$signing_list"' EXIT
find "$APP/Contents/Resources/playwright-runtime" -type f -print > "$signing_list"
while IFS= read -r executable; do
if file "$executable" | grep -q 'Mach-O'; then
sign_code "$executable" || exit 1
sign_code "$executable"
fi
# `set -e` is not reliable for a while loop in a pipeline on macOS /bin/sh.
# Exit explicitly so a failed child signature reaches the parent script.
done || exit 1
done < "$signing_list"
find "$APP/Contents/Resources/playwright-runtime" -depth -type d \
\( -name '*.framework' -o -name '*.xpc' -o -name '*.app' \) -print |
while IFS= read -r nested_bundle; do
sign_nested_bundle "$nested_bundle" || exit 1
done || exit 1
\( -name '*.framework' -o -name '*.xpc' -o -name '*.app' \) -print > "$signing_list"
while IFS= read -r nested_bundle; do
sign_nested_bundle "$nested_bundle"
done < "$signing_list"
# macOS 代码签名必须从内部组件开始,最后再签名 App 包本身。
sign_code "$APP/Contents/Helpers/xianyu-server"