فهرست منبع

ci: main 上的 release 预热也按 Rust 变更门控

前端 PR 合进 main 仍会拉起 Linux/macOS/Windows 三平台 cargo build --release。
Detect changes 改为 push 也跑;release-compile 只在 src-tauri 有改动或手动
dispatch 时预热。debug check 继续只在 PR 上跑。

Co-authored-by: darknessomi <darknessomi@users.noreply.github.com>
Cursor Agent 4 هفته پیش
والد
کامیت
745d00d5c8
1فایلهای تغییر یافته به همراه14 افزوده شده و 7 حذف شده
  1. 14 7
      .github/workflows/ci.yml

+ 14 - 7
.github/workflows/ci.yml

@@ -10,17 +10,18 @@ on:
 jobs:
   changes:
     name: Detect changes
-    if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
     runs-on: ubuntu-22.04
     outputs:
       rust: ${{ github.event_name == 'workflow_dispatch' && 'true' || steps.filter.outputs.rust }}
     steps:
       - name: Checkout
-        if: github.event_name == 'pull_request'
+        if: github.event_name != 'workflow_dispatch'
         uses: actions/checkout@v5
+        with:
+          fetch-depth: 0
 
       - name: Filter paths
-        if: github.event_name == 'pull_request'
+        if: github.event_name != 'workflow_dispatch'
         uses: dorny/paths-filter@v3
         id: filter
         with:
@@ -33,6 +34,7 @@ jobs:
   check:
     name: Check Ubuntu
     needs: changes
+    if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
     runs-on: ubuntu-22.04
     steps:
       - name: Checkout
@@ -71,7 +73,9 @@ jobs:
   check-windows:
     name: Check Windows (Rust)
     needs: changes
-    if: needs.changes.outputs.rust == 'true'
+    if: >-
+      (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch') &&
+      needs.changes.outputs.rust == 'true'
     runs-on: windows-latest
     steps:
       - name: Checkout
@@ -96,10 +100,12 @@ jobs:
         run: cargo build
 
   # Warm target/release on the default branch so tag builds can restore it.
-  # GitHub cache is ref-scoped: tags cannot see other tags, but they can see main.
+  # Only when src-tauri changes (or manual dispatch). Frontend merges must not
+  # pay for a 3-platform release compile.
   release-compile:
     name: Release compile ${{ matrix.display }}
-    if: github.event_name != 'pull_request'
+    needs: changes
+    if: github.event_name != 'pull_request' && needs.changes.outputs.rust == 'true'
     runs-on: ${{ matrix.platform }}
     env:
       CARGO_PROFILE_RELEASE_LTO: "false"
@@ -159,7 +165,8 @@ jobs:
 
   release-compile-windows:
     name: Release compile Windows x64
-    if: github.event_name != 'pull_request'
+    needs: changes
+    if: github.event_name != 'pull_request' && needs.changes.outputs.rust == 'true'
     runs-on: windows-latest
     env:
       CARGO_PROFILE_RELEASE_LTO: "false"