Cache Rust Dependencies in release.yml. (#1079)

This commit is contained in:
Cameron Campbell
2025-07-23 00:13:23 +01:00
committed by GitHub
parent 7860f2717f
commit 6dfdfbe514
2 changed files with 70 additions and 12 deletions

View File

@@ -26,8 +26,14 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Restore Rust Cache
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Setup Aftman
uses: ok-nick/setup-aftman@v0.4.2
@@ -40,6 +46,15 @@ jobs:
- name: Test
run: cargo test --locked --verbose
- name: Save Rust Cache
uses: actions/cache/save@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
msrv:
name: Check MSRV
runs-on: ubuntu-latest
@@ -52,8 +67,14 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@1.70.0
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Restore Rust Cache
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Setup Aftman
uses: ok-nick/setup-aftman@v0.4.2
@@ -63,6 +84,15 @@ jobs:
- name: Build
run: cargo build --locked --verbose
- name: Save Rust Cache
uses: actions/cache/save@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
lint:
name: Rustfmt, Clippy, Stylua, & Selene
runs-on: ubuntu-latest
@@ -77,8 +107,14 @@ jobs:
with:
components: rustfmt, clippy
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Restore Rust Cache
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Setup Aftman
uses: ok-nick/setup-aftman@v0.4.2
@@ -97,3 +133,11 @@ jobs:
- name: Clippy
run: cargo clippy
- name: Save Rust Cache
uses: actions/cache/save@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

View File

@@ -86,6 +86,15 @@ jobs:
with:
targets: ${{ matrix.target }}
- name: Restore Rust Cache
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Setup Aftman
uses: ok-nick/setup-aftman@v0.4.2
with:
@@ -93,10 +102,15 @@ jobs:
- name: Build Release
run: cargo build --release --locked --verbose --target ${{ matrix.target }}
env:
# Build into a known directory so we can find our build artifact more
# easily.
CARGO_TARGET_DIR: output
- name: Save Rust Cache
uses: actions/cache/save@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Generate Artifact Name
shell: bash
@@ -113,11 +127,11 @@ jobs:
mkdir staging
if [ "${{ matrix.host }}" = "windows" ]; then
cp "output/${{ matrix.target }}/release/$BIN.exe" staging/
cp "target/${{ matrix.target }}/release/$BIN.exe" staging/
cd staging
7z a ../$ARTIFACT_NAME *
else
cp "output/${{ matrix.target }}/release/$BIN" staging/
cp "target/${{ matrix.target }}/release/$BIN" staging/
cd staging
zip ../$ARTIFACT_NAME *
fi