From 3aabc3e8e4331fee5e4eb482d065c5d440c1a53d Mon Sep 17 00:00:00 2001 From: Christ Date: Wed, 12 Aug 2026 01:13:45 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E7=BC=93=E5=AD=98=E6=A1=8C=E9=9D=A2?= =?UTF-8?q?=E7=AB=AF=20Chromium=20runtime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为 Windows amd64 以及 macOS arm64 和 amd64 runtime 增加 GitHub Actions 缓存。 缓存键绑定操作系统、架构和 go.mod 哈希;命中缓存时跳过 Chromium 与 Playwright driver 下载,Playwright 版本变化后自动生成新缓存。 使用 actions/cache@v6,并通过 cache-hit 控制 runtime 预下载步骤。 --- .github/workflows/desktop-cd.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/desktop-cd.yml b/.github/workflows/desktop-cd.yml index 3367a21..6e4cb11 100644 --- a/.github/workflows/desktop-cd.yml +++ b/.github/workflows/desktop-cd.yml @@ -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