From acc49bf941182027ed40e09ac751c35c9a4325f8 Mon Sep 17 00:00:00 2001 From: sunss Date: Fri, 30 Jan 2026 16:15:21 +0800 Subject: [PATCH 1/4] docs: add release cache design --- docs/plans/2026-01-30-release-cache-design.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 docs/plans/2026-01-30-release-cache-design.md diff --git a/docs/plans/2026-01-30-release-cache-design.md b/docs/plans/2026-01-30-release-cache-design.md new file mode 100644 index 0000000..e5bbee6 --- /dev/null +++ b/docs/plans/2026-01-30-release-cache-design.md @@ -0,0 +1,19 @@ +# Release 构建缓存优化设计 + +## 目标 +- 缩短多平台 release 构建时间,减少重复安装与编译。 +- 保持发布流程与构建产物不变,仅增加缓存。 + +## 方案概述 +- 在 release workflow 的 build job 中增加两类缓存: + 1) pnpm store cache:加速依赖安装。 + 2) Rust cache:缓存 `~/.cargo` 与 `src-tauri/target`,提升增量编译速度。 + +## 实现要点 +- 使用 `actions/cache@v4` 缓存 pnpm store,key 由 `pnpm-lock.yaml` 与 OS 组成。 +- 使用 `Swatinem/rust-cache@v2` 缓存 Rust build artefacts,绑定 `src-tauri` 目录。 +- 不改变平台矩阵、不修改发布逻辑。 + +## 验证策略 +- 工作流改动无法本地自动化测试,需通过一次 PR 合并触发验证。 +- 观察 Actions 中 build job 的 “Cache hit” 日志与时长变化。 From 3987338f8229e8e63fa3dc80b8d73a91d877b226 Mon Sep 17 00:00:00 2001 From: sunss Date: Fri, 30 Jan 2026 16:16:03 +0800 Subject: [PATCH 2/4] docs: add release cache plan --- docs/plans/2026-01-30-release-cache.md | 80 ++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 docs/plans/2026-01-30-release-cache.md diff --git a/docs/plans/2026-01-30-release-cache.md b/docs/plans/2026-01-30-release-cache.md new file mode 100644 index 0000000..2e960ba --- /dev/null +++ b/docs/plans/2026-01-30-release-cache.md @@ -0,0 +1,80 @@ +# Release 构建缓存优化 Implementation Plan + +> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. + +**Goal:** 为 release build job 增加 pnpm 与 Rust 缓存,缩短多平台构建时间。 + +**Architecture:** 在 release workflow 的 build job 中增加 pnpm store cache 与 rust-cache,不改变构建矩阵与发布逻辑。 + +**Tech Stack:** GitHub Actions, pnpm, rust-cache + +--- + +### Task 1: 增加 pnpm store 缓存 + +**Files:** +- Modify: `.github/workflows/release.yml` + +**Step 1: 写“失败用例”说明(workflow 配置无法自动化 TDD)** + +记录:workflow 变更无法在本地自动化测试,需通过 PR 合并行为验证(已取得用户许可)。 + +**Step 2: 添加 pnpm store cache** + +在 build job 中 `Setup Node` 之后插入: +```yaml + - name: Get pnpm store path + id: pnpm-store + run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" + + - name: Cache pnpm store + uses: actions/cache@v4 + with: + path: ${{ steps.pnpm-store.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- +``` + +**Step 3: Commit** +```bash +git add .github/workflows/release.yml + +git commit -m "ci: add pnpm cache to release build" +``` + +--- + +### Task 2: 增加 Rust 编译缓存 + +**Files:** +- Modify: `.github/workflows/release.yml` + +**Step 1: 添加 rust-cache** + +在 build job 中 pnpm cache 之后插入: +```yaml + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + workspaces: "src-tauri -> target" +``` + +**Step 2: Commit** +```bash +git add .github/workflows/release.yml + +git commit -m "ci: add rust cache to release build" +``` + +--- + +### Task 3: 验证与手动测试 + +**Step 1: 静态检查** +Run: `yq` / `yamllint`(如仓库存在)或手动检查 YAML 语法。 + +**Step 2: 手动验证** +- 合并 dev → main 的 PR +- 观察 Actions build job 日志中 cache hit 与耗时下降 + From cf5054fb03376e6dd49c36367ac819c79b64103b Mon Sep 17 00:00:00 2001 From: sunss Date: Fri, 30 Jan 2026 16:19:11 +0800 Subject: [PATCH 3/4] ci: add pnpm cache to release build --- .github/workflows/release.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b2a994..0ab7a22 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -118,6 +118,18 @@ jobs: node-version: 20 cache: pnpm + - name: Get pnpm store path + id: pnpm-store + run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" + + - name: Cache pnpm store + uses: actions/cache@v4 + with: + path: ${{ steps.pnpm-store.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- + - name: Verify pnpm run: pnpm --version From 106fc8153db178334a67fa121f9c02473e268a08 Mon Sep 17 00:00:00 2001 From: sunss Date: Fri, 30 Jan 2026 16:19:53 +0800 Subject: [PATCH 4/4] ci: add rust cache to release build --- .github/workflows/release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0ab7a22..0905171 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -130,6 +130,11 @@ jobs: restore-keys: | ${{ runner.os }}-pnpm- + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + workspaces: "src-tauri -> target" + - name: Verify pnpm run: pnpm --version