Преглед на файлове

【修复】分离客户端和服务端的编译流程

- 将原有的 build-app.yaml 文件重命名为 build-client.yaml,专注于客户端编译
- 新增 build-server.yaml 文件,用于服务端编译
- 更新工作流名称、路径触发条件和编译步骤,以适应新的分离结构
- 优化缓存使用和包上传逻辑,提高编译效率
PJ568 преди 1 година
родител
ревизия
72e6116d5a
променени са 4 файла, в които са добавени 109 реда и са изтрити 20 реда
  1. 8 18
      .github/workflows/build-client.yaml
  2. 99 0
      .github/workflows/build-server.yaml
  3. 1 1
      Cargo.lock
  4. 1 1
      Cargo.toml

+ 8 - 18
.github/workflows/build-app.yaml → .github/workflows/build-client.yaml

@@ -1,15 +1,14 @@
-name: 编译
+name: 编译客户端
 
 on:
   workflow_dispatch:
   push:
     paths:
-      - '.github/workflows/build-app.yaml'
+      - '.github/workflows/build-client.yaml'
       - 'client/**'
-      - 'src/**'
 
 concurrency:
-  group: "build"
+  group: "client"
   cancel-in-progress: true
 
 permissions:
@@ -35,7 +34,7 @@ jobs:
 
   build-app:
     needs: get-version
-    name: 编译(${{ matrix.os }})
+    name: 编译客户端(${{ matrix.os }})
     runs-on: ${{ matrix.os }}
     env:
       HTML_PATH: 'client/index.html'
@@ -111,10 +110,6 @@ jobs:
         run: |
           npm install -g shelljs
           npm install -g axios
-
-      - name: 编译服务端
-        run: |
-          cargo build --release
     
       - name: 编译客户端
         run: |
@@ -132,20 +127,15 @@ jobs:
 
       - name: 收集包
         run: |
-          mkdir -p yaa-${{ matrix.build }}
-          cp -r node_modules/pake-cli/output/* yaa-${{ matrix.build }}
-          if [ "${{ matrix.os }}" == "windows-latest" ]; then
-            cp target/release/yaa.exe yaa-${{ matrix.build }}/
-          else
-            cp target/release/yaa yaa-${{ matrix.build }}/
-          fi
+          mkdir -p yaa_client_${{ matrix.build }}
+          cp -r target/client/* yaa_client_${{ matrix.build }}
         shell: bash
 
       - name: 上传包
         uses: actions/upload-artifact@v4
         with:
-          name: yaa-${{ matrix.os }}.zip
-          path: yaa-${{ matrix.build }}/**/*
+          name: yaa_client_${{ matrix.os }}.zip
+          path: yaa_client_${{ matrix.build }}/**/*
           retention-days: 3
 
       - name: 保存 Rust 缓存

+ 99 - 0
.github/workflows/build-server.yaml

@@ -0,0 +1,99 @@
+name: 编译服务端
+
+on:
+  workflow_dispatch:
+  push:
+    paths:
+      - '.github/workflows/build-server.yaml'
+      - 'src/**'
+
+concurrency:
+  group: "server"
+  cancel-in-progress: true
+
+permissions:
+  contents: read
+  id-token: write
+
+jobs:
+  build-server:
+    name: 编译服务端(${{ matrix.os }})
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        build: [linux, macos, windows]
+        include:
+          - build: linux
+            os: ubuntu-latest
+          - build: windows
+            os: windows-latest
+          - build: macos
+            os: macos-latest
+    steps:
+
+      - name: 检出仓库
+        uses: actions/checkout@v4
+
+      - name: 为 ubuntu-latest 安装 Rust
+        if: matrix.os == 'ubuntu-latest'
+        uses: dtolnay/rust-toolchain@stable
+        with:
+          toolchain: stable
+          target: x86_64-unknown-linux-musl
+
+      - name: 为 windows-latest 安装 Rust
+        if: matrix.os == 'windows-latest'
+        uses: dtolnay/rust-toolchain@stable
+        with:
+          toolchain: stable-x86_64-msvc
+          target: x86_64-pc-windows-msvc
+
+      - name: 为 macos-latest 安装 Rust
+        if: matrix.os == 'macos-latest'
+        uses: dtolnay/rust-toolchain@stable
+        with:
+          toolchain: stable
+          target: x86_64-apple-darwin
+
+      - name: 恢复 Rust 缓存
+        uses: actions/cache/restore@v3
+        id: cache_store
+        with:
+          path: |
+            ~/.cargo/bin/
+            ~/.cargo/registry/index/
+            ~/.cargo/registry/cache/
+            ~/.cargo/git/db/
+          key: ${{ matrix.os }}-cargo-${{ hashFiles('./Cargo.lock') }}
+
+      - name: 编译服务端
+        run: |
+          cargo build --release
+
+      - name: 收集包
+        run: |
+          mkdir -p yaa_server_${{ matrix.build }}
+          if [ "${{ matrix.os }}" == "windows-latest" ]; then
+            cp target/release/yaa.exe yaa_server_${{ matrix.build }}/
+          else
+            cp target/release/yaa yaa_server_${{ matrix.build }}/
+          fi
+        shell: bash
+
+      - name: 上传包
+        uses: actions/upload-artifact@v4
+        with:
+          name: yaa_server_${{ matrix.os }}.zip
+          path: yaa_server_${{ matrix.build }}/**/*
+          retention-days: 3
+
+      - name: 保存 Rust 缓存
+        uses: actions/cache/save@v3
+        if: steps.cache_store.outputs.cache-hit != 'true'
+        with:
+          path: |
+            ~/.cargo/bin/
+            ~/.cargo/registry/index/
+            ~/.cargo/registry/cache/
+            ~/.cargo/git/db/
+          key: ${{ matrix.os }}-cargo-${{ hashFiles('./Cargo.lock') }}

+ 1 - 1
Cargo.lock

@@ -2449,7 +2449,7 @@ checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
 
 [[package]]
 name = "yaa"
-version = "2.8.2"
+version = "2.8.3"
 dependencies = [
  "actix-cors",
  "actix-web",

+ 1 - 1
Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "yaa"
-version = "2.8.2"
+version = "2.8.3"
 edition = "2024"
 
 [dependencies]