Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ 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: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: "src-tauri -> target"

- name: Verify pnpm
run: pnpm --version

Expand Down
19 changes: 19 additions & 0 deletions docs/plans/2026-01-30-release-cache-design.md
Original file line number Diff line number Diff line change
@@ -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” 日志与时长变化。
80 changes: 80 additions & 0 deletions docs/plans/2026-01-30-release-cache.md
Original file line number Diff line number Diff line change
@@ -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 与耗时下降