ci: 缓存桌面端 Chromium runtime

为 Windows amd64 以及 macOS arm64 和 amd64 runtime 增加 GitHub Actions 缓存。

缓存键绑定操作系统、架构和 go.mod 哈希;命中缓存时跳过 Chromium 与 Playwright driver 下载,Playwright 版本变化后自动生成新缓存。

使用 actions/cache@v6,并通过 cache-hit 控制 runtime 预下载步骤。
This commit is contained in:
Christ committed 2026-08-12 01:13:45 +08:00
1 parent 1ac6912c7b
commit 3aabc3e8e4
1 file changed
+18
+18
View File
@@ -99,7 +99,15 @@ jobs:
go build -trimpath -ldflags "-s -w" -o dist/windows/browser-install.exe ./cmd/browser-install
go build -trimpath -ldflags "-s -w -H=windowsgui" -o dist/windows/xianyu-tray.exe ./cmd/tray
- name: 缓存 Windows Chromium runtime
id: cache-windows-playwright
uses: actions/cache@v6
with:
path: dist/windows/playwright-runtime/amd64
key: ydisks-playwright-runtime-v1-windows-amd64-${{ hashFiles('go.mod') }}
- name: 预下载 Windows Chromium runtime
if: steps.cache-windows-playwright.outputs.cache-hit != 'true'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist/windows/playwright-runtime/amd64/playwright-driver | Out-Null
@@ -205,7 +213,17 @@ jobs:
GOOS=darwin GOARCH="$arch" CGO_ENABLED=1 go build -trimpath -ldflags='-s -w' -o "dist/macos/$arch/xianyu-tray" ./cmd/tray
done
- name: 缓存 macOS Chromium runtime
id: cache-macos-playwright
uses: actions/cache@v6
with:
path: |
dist/macos/playwright-runtime/arm64
dist/macos/playwright-runtime/amd64
key: ydisks-playwright-runtime-v1-macos-universal-${{ hashFiles('go.mod') }}
- name: 预下载 macOS Chromium runtime
if: steps.cache-macos-playwright.outputs.cache-hit != 'true'
run: |
set -Eeuo pipefail
mkdir -p dist/macos/playwright-runtime/arm64/playwright-driver