diff --git a/.gitea/actions/rust-cache/action.yml b/.gitea/actions/rust-cache/action.yml index 48ebe1e..62be3ef 100644 --- a/.gitea/actions/rust-cache/action.yml +++ b/.gitea/actions/rust-cache/action.yml @@ -16,6 +16,17 @@ outputs: runs: using: composite steps: + # Gitea Actions does not have Cargo.lock by default (cargo generates it on first build), + # and hashFiles() globs don't work reliably here. Use shell hashing instead. + - name: Compute cache key + id: cache-key + shell: bash + run: | + # Hash both files; if Cargo.lock doesn't exist yet, only Cargo.toml is hashed + HASH=$(cat Cargo.toml Cargo.lock 2>/dev/null | sha256sum | cut -d' ' -f1) + echo "hash=$HASH" >> $GITHUB_OUTPUT + echo "fingerprint=$HASH" >> $GITHUB_ENV + - name: Cache cargo + rustup id: cache uses: https://gitea.com/actions/cache@v3 @@ -26,10 +37,8 @@ runs: ~/.rustup/toolchains ~/.rustup/settings.toml target - key: rust-linux-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/Cargo.toml') }} - restore-keys: | - rust-linux-${{ hashFiles('**/Cargo.lock') }}- - rust-linux- + key: rust-linux-${{ steps.cache-key.outputs.hash }} + restore-keys: rust-linux- - name: Setup Rust shell: bash