From 9f5feb03bbf10d174bc03a1f75f821536b0c4d40 Mon Sep 17 00:00:00 2001 From: Thomas Nemer Date: Sat, 21 Feb 2026 13:35:17 +0100 Subject: [PATCH] Add cargo caching to release workflows Use the same Cargo.lock hashing strategy as CI, with runner.os and runner.arch in the cache key to keep per-platform caches separate. Also update CI to use runner.os instead of hardcoded "linux" for consistency. --- .github/workflows/ci.yml | 2 +- .github/workflows/release-linux-aarch64.yml | 14 ++++++++++++++ .github/workflows/release-linux-x86_64.yml | 14 ++++++++++++++ .github/workflows/release-macos-aarch64.yml | 14 ++++++++++++++ .github/workflows/release-macos-x86_64.yml | 14 ++++++++++++++ .github/workflows/release-windows-x86_64.yml | 15 +++++++++++++++ 6 files changed, 72 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2679295..e824d55 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,5 +25,5 @@ jobs: path: | ~/.cargo target - key: v0-linux-${{ runner.arch }}-${{ steps.cache-key.outputs.cargo-lock-hash }} + key: v0-${{ runner.os }}-${{ runner.arch }}-${{ steps.cache-key.outputs.cargo-lock-hash }} - run: mise run check diff --git a/.github/workflows/release-linux-aarch64.yml b/.github/workflows/release-linux-aarch64.yml index 913c228..8e2df20 100644 --- a/.github/workflows/release-linux-aarch64.yml +++ b/.github/workflows/release-linux-aarch64.yml @@ -15,8 +15,22 @@ jobs: with: fetch-depth: 0 + - name: Prepare cache key + id: cache-key + run: | + # Hash Cargo.lock excluding the data-breaker package version line for stable caching + HASH=$(grep -n 'name = "data-breaker"' Cargo.lock | head -1 | cut -d: -f1 | xargs -I{} expr {} + 1 | xargs -I{} sed '{}d' Cargo.lock | sha256sum | cut -d' ' -f1) + echo "cargo-lock-hash=$HASH" >> "$GITHUB_OUTPUT" + - uses: jdx/mise-action@v2 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo + target + key: v0-${{ runner.os }}-${{ runner.arch }}-${{ steps.cache-key.outputs.cargo-lock-hash }} + - name: Add target run: rustup target add aarch64-unknown-linux-gnu diff --git a/.github/workflows/release-linux-x86_64.yml b/.github/workflows/release-linux-x86_64.yml index a3f99a5..ff0b287 100644 --- a/.github/workflows/release-linux-x86_64.yml +++ b/.github/workflows/release-linux-x86_64.yml @@ -15,8 +15,22 @@ jobs: with: fetch-depth: 0 + - name: Prepare cache key + id: cache-key + run: | + # Hash Cargo.lock excluding the data-breaker package version line for stable caching + HASH=$(grep -n 'name = "data-breaker"' Cargo.lock | head -1 | cut -d: -f1 | xargs -I{} expr {} + 1 | xargs -I{} sed '{}d' Cargo.lock | sha256sum | cut -d' ' -f1) + echo "cargo-lock-hash=$HASH" >> "$GITHUB_OUTPUT" + - uses: jdx/mise-action@v2 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo + target + key: v0-${{ runner.os }}-${{ runner.arch }}-${{ steps.cache-key.outputs.cargo-lock-hash }} + - name: Add target run: rustup target add x86_64-unknown-linux-gnu diff --git a/.github/workflows/release-macos-aarch64.yml b/.github/workflows/release-macos-aarch64.yml index eaec542..930f439 100644 --- a/.github/workflows/release-macos-aarch64.yml +++ b/.github/workflows/release-macos-aarch64.yml @@ -15,8 +15,22 @@ jobs: with: fetch-depth: 0 + - name: Prepare cache key + id: cache-key + run: | + # Hash Cargo.lock excluding the data-breaker package version line for stable caching + HASH=$(grep -n 'name = "data-breaker"' Cargo.lock | head -1 | cut -d: -f1 | xargs -I{} expr {} + 1 | xargs -I{} sed '{}d' Cargo.lock | sha256sum | cut -d' ' -f1) + echo "cargo-lock-hash=$HASH" >> "$GITHUB_OUTPUT" + - uses: jdx/mise-action@v2 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo + target + key: v0-${{ runner.os }}-${{ runner.arch }}-${{ steps.cache-key.outputs.cargo-lock-hash }} + - name: Add target run: rustup target add aarch64-apple-darwin diff --git a/.github/workflows/release-macos-x86_64.yml b/.github/workflows/release-macos-x86_64.yml index f99d44f..66a27b3 100644 --- a/.github/workflows/release-macos-x86_64.yml +++ b/.github/workflows/release-macos-x86_64.yml @@ -15,8 +15,22 @@ jobs: with: fetch-depth: 0 + - name: Prepare cache key + id: cache-key + run: | + # Hash Cargo.lock excluding the data-breaker package version line for stable caching + HASH=$(grep -n 'name = "data-breaker"' Cargo.lock | head -1 | cut -d: -f1 | xargs -I{} expr {} + 1 | xargs -I{} sed '{}d' Cargo.lock | sha256sum | cut -d' ' -f1) + echo "cargo-lock-hash=$HASH" >> "$GITHUB_OUTPUT" + - uses: jdx/mise-action@v2 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo + target + key: v0-${{ runner.os }}-${{ runner.arch }}-${{ steps.cache-key.outputs.cargo-lock-hash }} + - name: Add target run: rustup target add x86_64-apple-darwin diff --git a/.github/workflows/release-windows-x86_64.yml b/.github/workflows/release-windows-x86_64.yml index f879893..d35179c 100644 --- a/.github/workflows/release-windows-x86_64.yml +++ b/.github/workflows/release-windows-x86_64.yml @@ -15,8 +15,23 @@ jobs: with: fetch-depth: 0 + - name: Prepare cache key + id: cache-key + shell: bash + run: | + # Hash Cargo.lock excluding the data-breaker package version line for stable caching + HASH=$(grep -n 'name = "data-breaker"' Cargo.lock | head -1 | cut -d: -f1 | xargs -I{} expr {} + 1 | xargs -I{} sed '{}d' Cargo.lock | sha256sum | cut -d' ' -f1) + echo "cargo-lock-hash=$HASH" >> "$GITHUB_OUTPUT" + - uses: jdx/mise-action@v2 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo + target + key: v0-${{ runner.os }}-${{ runner.arch }}-${{ steps.cache-key.outputs.cargo-lock-hash }} + - name: Build run: cargo build --release --target x86_64-pc-windows-msvc