From 814f23a27c98eb1f93c941767603adb55f24bcd6 Mon Sep 17 00:00:00 2001 From: mofeng-git Date: Fri, 31 Jul 2026 09:55:14 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E4=BC=98=E5=8C=96=20Cargo=20=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 共享 deb 与 Docker 的 Linux cross 编译缓存 - 为 Windows MSVC 构建添加独立缓存 - 固定 cross 版本以保证缓存一致性 --- .github/workflows/build.yml | 16 +++++++++++++++- .github/workflows/docker.yml | 10 +++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47b26c5f..25cf087f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,8 +66,16 @@ jobs: - uses: dtolnay/rust-toolchain@stable + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + # The Docker workflow builds the same targets with the same Cross images. + shared-key: linux-cross-release + key: ${{ hashFiles('Cross.toml', 'build/cross/Dockerfile.*') }} + cache-all-crates: true + - name: Install cross - run: cargo install cross --locked + run: cargo install cross --version 0.2.5 --locked - name: Build linux binary run: bash build/build-images.sh @@ -127,6 +135,12 @@ jobs: "TURBOJPEG_LIB_DIR=$env:TURBOJPEG_LIB_DIR" | Out-File -FilePath $env:GITHUB_ENV -Append "TURBOJPEG_INCLUDE_DIR=$env:TURBOJPEG_INCLUDE_DIR" | Out-File -FilePath $env:GITHUB_ENV -Append + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: windows-msvc-release + key: ${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }} + - name: Build Windows exe shell: pwsh run: .\build\windows\build.ps1 -Configuration release -Package diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f71ab055..dd411487 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -42,11 +42,19 @@ jobs: - uses: dtolnay/rust-toolchain@stable + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + # Reuse dependency artifacts produced by the deb job and vice versa. + shared-key: linux-cross-release + key: ${{ hashFiles('Cross.toml', 'build/cross/Dockerfile.*') }} + cache-all-crates: true + - name: Install build dependencies run: | sudo apt-get update sudo apt-get install -y unzip xz-utils - cargo install cross --locked + cargo install cross --version 0.2.5 --locked - name: Build frontend working-directory: web