@@ -36,19 +36,30 @@ jobs:
3636 - name : Checkout repository
3737 uses : actions/checkout@v6
3838
39+ - name : Cache built binary
40+ id : bin-cache
41+ uses : actions/cache@v4
42+ with :
43+ path : |
44+ ${{ matrix.asset_name }}.gz
45+ ${{ matrix.asset_name }}.zip
46+ key : gnd-${{ matrix.target }}-${{ hashFiles('Cargo.lock', '**/Cargo.toml', '**/*.rs') }}
47+
3948 - name : Install Rust toolchain
49+ if : steps.bin-cache.outputs.cache-hit != 'true'
4050 run : |
4151 rustup toolchain install stable
4252 rustup target add ${{ matrix.target }}
4353 rustup default stable
4454
4555 - name : Rust Cache
56+ if : steps.bin-cache.outputs.cache-hit != 'true'
4657 uses : Swatinem/rust-cache@v2
4758 with :
4859 key : ${{ matrix.target }}
4960
5061 - name : Install dependencies (Ubuntu)
51- if : startsWith(matrix.runner, 'ubuntu')
62+ if : steps.bin-cache.outputs.cache-hit != 'true' && startsWith(matrix.runner, 'ubuntu')
5263 run : |
5364 sudo apt-get update
5465 sudo apt-get install -y protobuf-compiler musl-tools
@@ -57,27 +68,26 @@ jobs:
5768 fi
5869
5970 - name : Install dependencies (macOS)
60- if : startsWith(matrix.runner, 'macos')
71+ if : steps.bin-cache.outputs.cache-hit != 'true' && startsWith(matrix.runner, 'macos')
6172 run : |
6273 brew install protobuf
6374
6475 - name : Install protobuf (Windows)
65- if : startsWith(matrix.runner, 'windows')
76+ if : steps.bin-cache.outputs.cache-hit != 'true' && startsWith(matrix.runner, 'windows')
6677 run : choco install protoc
6778
68-
6979 - name : Build gnd binary (Unix/Mac)
70- if : ${{ ! startsWith(matrix.runner, 'windows') }}
80+ if : steps.bin-cache.outputs.cache-hit != 'true' && ! startsWith(matrix.runner, 'windows')
7181 run : cargo build --bin gnd --release --target ${{ matrix.target }}
7282 env :
7383 CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER : aarch64-linux-gnu-gcc
7484
7585 - name : Build gnd binary (Windows)
76- if : startsWith(matrix.runner, 'windows')
86+ if : steps.bin-cache.outputs.cache-hit != 'true' && startsWith(matrix.runner, 'windows')
7787 run : cargo build --bin gnd --release --target ${{ matrix.target }}
7888
7989 - name : Sign macOS binary
80- if : startsWith(matrix.runner, 'macos')
90+ if : steps.bin-cache.outputs.cache-hit != 'true' && startsWith(matrix.runner, 'macos')
8191 uses : lando/code-sign-action@v3
8292 with :
8393 file : target/${{ matrix.target }}/release/gnd
8797 options : --options runtime --entitlements entitlements.plist
8898
8999 - name : Notarize macOS binary
90- if : startsWith(matrix.runner, 'macos')
100+ if : steps.bin-cache.outputs.cache-hit != 'true' && startsWith(matrix.runner, 'macos')
91101 uses : lando/notarize-action@v2
92102 with :
93103 product-path : target/${{ matrix.target }}/release/gnd
@@ -96,14 +106,14 @@ jobs:
96106 appstore-connect-team-id : ${{ secrets.APPLE_TEAM_ID }}
97107
98108 - name : Prepare binary (Unix)
99- if : ${{ ! startsWith(matrix.runner, 'windows') }}
109+ if : steps.bin-cache.outputs.cache-hit != 'true' && ! startsWith(matrix.runner, 'windows')
100110 run : |
101111 cp target/${{ matrix.target }}/release/gnd ${{ matrix.asset_name }}
102112 chmod +x ${{ matrix.asset_name }}
103113 gzip ${{ matrix.asset_name }}
104114
105115 - name : Prepare binary (Windows)
106- if : startsWith(matrix.runner, 'windows')
116+ if : steps.bin-cache.outputs.cache-hit != 'true' && startsWith(matrix.runner, 'windows')
107117 run : |
108118 copy target\${{ matrix.target }}\release\gnd.exe ${{ matrix.asset_name }}
109119 7z a -tzip ${{ matrix.asset_name }}.zip ${{ matrix.asset_name }}
0 commit comments