Browse Source

ci: 拆开 Windows release-compile job,避开 matrix if 校验失败

Co-authored-by: darknessomi <darknessomi@users.noreply.github.com>
Cursor Agent 2 months ago
parent
commit
91501acaf4
1 changed files with 40 additions and 8 deletions
  1. 40 8
      .github/workflows/ci.yml

+ 40 - 8
.github/workflows/ci.yml

@@ -65,12 +65,12 @@ jobs:
         working-directory: src-tauri
         run: cargo build
 
-  # Warm target/release on the default branch so tag builds can restore it.
+  # Warm target/release so tag builds can restore it from the default branch.
   # GitHub cache is ref-scoped: tags cannot see other tags, but they can see main.
   # Windows also runs on PRs so this branch can measure release compile time.
   release-compile:
     name: Release compile ${{ matrix.display }}
-    if: github.event_name != 'pull_request' || matrix.on_pr
+    if: github.event_name != 'pull_request'
     runs-on: ${{ matrix.platform }}
     env:
       CARGO_PROFILE_RELEASE_LTO: "false"
@@ -80,15 +80,10 @@ jobs:
       fail-fast: false
       matrix:
         include:
-          - platform: windows-latest
-            display: Windows x64
-            on_pr: true
           - platform: ubuntu-22.04
             display: Linux x64
-            on_pr: false
           - platform: macos-latest
             display: macOS
-            on_pr: false
 
     steps:
       - name: Checkout
@@ -109,8 +104,45 @@ jobs:
           sudo apt-get update
           sudo apt-get install -y curl libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf protobuf-compiler
 
+      - name: Rust cache
+        uses: Swatinem/rust-cache@v2
+        with:
+          workspaces: src-tauri
+          shared-key: qmai-release
+          add-job-id-key: false
+          cache-on-failure: true
+
+      - name: Setup Node.js
+        uses: actions/setup-node@v5
+        with:
+          node-version: 24
+          cache: npm
+
+      - name: Install frontend dependencies
+        run: npm ci
+
+      - name: Build frontend
+        run: npx vite build
+
+      - name: Cargo release build
+        working-directory: src-tauri
+        run: cargo build --release
+
+  release-compile-windows:
+    name: Release compile Windows x64
+    runs-on: windows-latest
+    env:
+      CARGO_PROFILE_RELEASE_LTO: "false"
+      CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "16"
+      CARGO_PROFILE_RELEASE_OPT_LEVEL: "1"
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v5
+
+      - name: Install Rust stable
+        uses: dtolnay/rust-toolchain@stable
+
       - name: Install protoc (Windows)
-        if: matrix.platform == 'windows-latest'
         uses: arduino/setup-protoc@v3
         with:
           repo-token: ${{ secrets.GITHUB_TOKEN }}