1313 RUST_BACKTRACE : 1
1414
1515jobs :
16+ # run `cargo vendor` and cache it
17+ vendor_sources :
18+ runs-on : ubuntu-latest
19+
20+ steps :
21+ - uses : actions/checkout@v3
22+
23+ - uses : actions/cache@v3
24+ name : Update crate cargo-vendor cache
25+ id : vendor_cache
26+ with :
27+ path : |
28+ .cargo
29+ vendor
30+ key : cargo-vendor-release-${{ hashFiles('**/Cargo.lock') }}
31+ restore-keys : |
32+ cargo-vendor-release
33+ cargo-vendor
34+ enableCrossOsArchive : true
35+
36+ - uses : actions/cache@v3
37+ name : Update cargo registry cache
38+ if : steps.vendor_cache.outputs.cache-hit != 'true'
39+ with :
40+ path : |
41+ ~/.cargo/bin/
42+ ~/.cargo/registry/index/
43+ ~/.cargo/registry/cache/
44+ ~/.cargo/git/db/
45+ key : ${{ runner.os }}-cargo-cache-release-${{ hashFiles('**/Cargo.lock') }}
46+ restore-keys : |
47+ ${{ runner.os }}-cargo-cache-release
48+ ${{ runner.os }}-cargo-cache
49+
50+ - name : Vendor sources
51+ if : steps.vendor_cache.outputs.cache-hit != 'true'
52+ run : |
53+ mkdir -p .cargo
54+ mkdir -p vendor
55+ cargo vendor --versioned-dirs --locked >.cargo/config.toml
56+
1657 # Linux builds, with Docker and qemu as required
1758 release_linux :
1859 runs-on : ubuntu-latest
1960
61+ needs : vendor_sources
62+
2063 env :
2164 # See <https://hub.docker.com/_/rust> for list of tags
2265 BUILD_RUST_TAG : 1.67.0
4992 steps :
5093 - uses : actions/checkout@v3
5194
95+ - uses : actions/cache/restore@v3
96+ name : Restore crate cargo-vendor cache
97+ with :
98+ path : |
99+ .cargo
100+ vendor
101+ key : cargo-vendor-release-${{ hashFiles('**/Cargo.lock') }}
102+ enableCrossOsArchive : true
103+ fail-on-cache-miss : true
104+
52105 - name : Workaround for https://github.com/rust-lang/cargo/issues/8719
53106 run : |
54107 sudo mkdir -p /var/lib/docker
84137 target : localfile
85138 build-args : |
86139 CARGO_BUILD_TARGET=${{ matrix.rust }}
140+ CARGO_NET_OFFLINE=true
87141 BUILD_OS_TAG=${{ matrix.os }}
88142 BUILD_RUST_TAG=${{ env.BUILD_RUST_TAG }}
89143 platforms : ${{ matrix.docker }}
@@ -131,9 +185,12 @@ jobs:
131185 release_windows :
132186 runs-on : windows-latest
133187
188+ needs : vendor_sources
189+
134190 env :
135191 CARGO_BUILD_TARGET : x86_64-pc-windows-msvc
136- CARGO_INSTALL_ROOT : ' install/'
192+ CARGO_NET_OFFLINE : " true"
193+ CARGO_INSTALL_ROOT : " install/"
137194 RUSTFLAGS : ' -C strip=symbols -C target-feature=+crt-static'
138195 samedec_exe : ' install/bin/samedec.exe'
139196 samedec_target_exe : install/bin/samedec-x86_64-pc-windows-msvc.exe
@@ -145,22 +202,20 @@ jobs:
145202 shell : bash
146203 run : cargo version
147204
148- - uses : actions/cache@v3
149- name : Restore Rust cache
205+ - uses : actions/cache/restore @v3
206+ name : Restore crate cargo-vendor cache
150207 with :
151208 path : |
152- ~/.cargo/bin/
153- ~/.cargo/registry/index/
154- ~/.cargo/registry/cache/
155- ~/.cargo/git/db/
156- target/
157- key : ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
209+ .cargo
210+ vendor
211+ key : cargo-vendor-release-${{ hashFiles('**/Cargo.lock') }}
212+ enableCrossOsArchive : true
213+ fail-on-cache-miss : true
158214
159215 - name : Build
160216 shell : bash
161217 run : |
162218 mkdir -p 'install' &&
163- cargo fetch --locked &&
164219 cargo build --offline --tests --frozen --release --workspace
165220
166221 - name : Test and install
@@ -218,9 +273,12 @@ jobs:
218273 release_macos :
219274 runs-on : macos-latest
220275
276+ needs : vendor_sources
277+
221278 env :
222279 CARGO_BUILD_TARGET : x86_64-apple-darwin
223- CARGO_INSTALL_ROOT : ' install/'
280+ CARGO_NET_OFFLINE : " true"
281+ CARGO_INSTALL_ROOT : " install/"
224282 RUSTFLAGS : ' -C strip=symbols'
225283 samedec_exe : ' install/bin/samedec'
226284 samedec_target_exe : install/bin/samedec-x86_64-apple-darwin
@@ -231,16 +289,15 @@ jobs:
231289 - name : Record environment
232290 run : cargo version
233291
234- - uses : actions/cache@v3
235- name : Restore Rust cache
292+ - uses : actions/cache/restore @v3
293+ name : Restore crate cargo-vendor cache
236294 with :
237295 path : |
238- ~/.cargo/bin/
239- ~/.cargo/registry/index/
240- ~/.cargo/registry/cache/
241- ~/.cargo/git/db/
242- target/
243- key : ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
296+ .cargo
297+ vendor
298+ key : cargo-vendor-release-${{ hashFiles('**/Cargo.lock') }}
299+ enableCrossOsArchive : true
300+ fail-on-cache-miss : true
244301
245302 - name : Build
246303 run : |
0 commit comments