1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
---
# BEGIN: cirrus-anchors.yml
anchors:
-
install_cargo_make_script: ./.ci/install-cargo-make.sh
-
install_cargo_make_script: .\.ci\install-cargo-make.ps1
-
build_cargo_make_cache:
folder: $CARGO_HOME/opt/cargo-make
fingerprint_script: |
echo "$CIRRUS_OS"
echo "${CI_CACHE_BUST:-}"
echo "$RUST_VERSION"
./.ci/install-cargo-make.sh --print-latest
populate_script: ./.ci/build-cargo-make.sh
link_cargo_make_script: ln -snf "$CARGO_HOME"/opt/*/bin/* "$CARGO_HOME"/bin/
-
build_cargo_make_cache:
folder: $CARGO_HOME\opt\cargo-make
fingerprint_script: |
$env:CIRRUS_OS
$env:CI_CACHE_BUST
$env:RUST_VERSION
.\.ci\install-cargo-make.ps1 -PrintLatest
populate_script: .\.ci\build-cargo-make.ps1
link_cargo_make_script: |
Get-ChildItem "$env:CARGO_HOME\opt\*\bin\*.exe" | ForEach-Object {
$dst = "$env:CARGO_HOME\bin\$($_.Name)"
if (-Not (Test-Path "$dst")) {
New-Item -Path "$dst" -Type SymbolicLink -Value "$_" | Out-Null
}
}
-
env:
CARGO_HOME: /usr/local/cargo
PATH: /usr/local/cargo/bin:$PATH
install_rustup_script: |
curl -sSfL https://sh.rustup.rs | sh -s -- \
-y --default-toolchain none --profile minimal --no-modify-path
install_rust_script: rustup default "$RUST_VERSION"
registry_cache:
folder: $CARGO_HOME/registry
fingerprint_script: |
if [ ! -f Cargo.lock ]; then
cargo generate-lockfile --quiet
fi
echo "${CI_CACHE_BUST:-}"
echo "${CIRRUS_OS}"
cat Cargo.lock
target_cache:
folder: target
fingerprint_script: |
if [ ! -f Cargo.lock ]; then
cargo generate-lockfile --quiet
fi
echo "${CI_CACHE_BUST:-}"
echo "$CIRRUS_TASK_NAME"
rustc --verbose --version
cat Cargo.lock
-
install_dependencies_script: |
if command -v yum >/dev/null; then
yum install -y unzip
else
apt-get install -y unzip
fi
<<: *base_unix
<<: *install_cargo_make_unix
-
<<: *base_unix
env:
CARGO_HOME: $HOME/.cargo
PATH: $HOME/.cargo/bin:$PATH
<<: *install_cargo_make_unix
-
<<: *base_unix
<<: *build_cargo_make_unix
-
env:
CIRRUS_SHELL: powershell
CARGO_HOME: $USERPROFILE\.cargo
PATH: $USERPROFILE\.cargo\bin;$PATH
install_rustup_script: |
& ([scriptblock]::Create((New-Object System.Net.WebClient).
DownloadString('https://gist.github.com/fnichol/699d3c2930649a9932f71bab8a315b31/raw/rustup-init.ps1')
)) -y --default-toolchain none --profile minimal
install_rust_script: rustup default "$env:RUST_VERSION"
registry_cache:
folder: $CARGO_HOME\registry
fingerprint_script: |
if (-Not (Test-Path "Cargo.lock")) {
cargo "+$env:RUST_VERSION" generate-lockfile --quiet
}
$env:CI_CACHE_BUST
$env:CIRRUS_OS
Get-Content Cargo.lock
target_cache:
folder: target
fingerprint_script: |
if (-Not (Test-Path "Cargo.lock")) {
cargo "+$env:RUST_VERSION" generate-lockfile --quiet
}
$env:CI_CACHE_BUST
$env:CIRRUS_TASK_NAME
rustc --verbose --version
Get-Content Cargo.lock
<<: *install_cargo_make_windows
-
install_rustup_target_script: rustup target install "$TARGET"
-
install_rustup_target_script: rustup target install "$env:TARGET"
-
build_script: |
if [ "${CIRRUS_TAG:-}" = "nightly" ]; then
export NIGHTLY_BUILD="$(date -u +%F)"
fi
cargo make build-release "--bin=$BIN" "--target=$TARGET"
strip_script: $STRIP "target/$TARGET/release/$BIN"
rename_script: cp "target/$TARGET/release/$BIN" "${BIN}-${TARGET}"
-
build_script: |
args=""
if [ -n "${FEATURES:-}" ]; then
args="--features $FEATURES"
fi
if [ -n "${NO_DEFAULT_FEATURES:-}" ]; then
args="$args --no-default-features"
fi
if [ -n "${ALL_FEATURES:-}" ]; then
args="$args --all-features"
fi
cargo make build-release "--lib=$LIB" "--target=$TARGET" $args
-
build_script: |
if ("$env:CIRRUS_TAG" -eq "nightly") {
$env:NIGHTLY_BUILD = $(Get-Date ([datetime]::UtcNow) -UFormat %Y-%m-%d)
}
cargo make build-release "--bin=$env:BIN" "--target=$env:TARGET"
rename_script: |
Copy-Item "target\$env:TARGET\release\$env:BIN.exe" "$env:BIN-$env:TARGET.exe"
-
build_script: |
$args = ""
if ("$env:FEATURES") {
$args = "--features $env:FEATURES"
}
if ("$env:NO_DEFAULT_FEATURES") {
$args = "$args --no-default-features"
}
if ("$env:ALL_FEATURES") {
$args = "$args --all-features"
}
cargo make build-release "--bin=$env:BIN" "--target=$env:TARGET" $args
-
cleanup_before_upload_cache_script: rm -rf "$CARGO_HOME/registry/index"
-
cleanup_before_upload_cache_script: |
if (Test-Path "$env:USERPROFILE\.cargo\registry\index") {
Remove-Item -Recurse -Force "$env:USERPROFILE\.cargo\registry\index"
}
# END: cirrus-anchors.yml
#
#
env:
RUST_VERSION: stable
MIN_SUPPORTED_RUST_VERSION: 1.54.0 # Due to clap v3
check_task:
name: check
only_if:
$CIRRUS_BRANCH !=~ ".*\.tmp" && $CIRRUS_BRANCH != $CIRRUS_DEFAULT_BRANCH
container:
image: rust:latest
<<: *base_linux
lint_script: cargo make check-lint
format_script: cargo make check-format
test_task:
name: test-${RUST_VERSION}-${TARGET}
alias: tests
only_if:
$CIRRUS_BRANCH !=~ ".*\.tmp" && $CIRRUS_BRANCH != $CIRRUS_DEFAULT_BRANCH
env:
matrix:
- RUST_VERSION: stable
- RUST_VERSION: nightly
- RUST_VERSION: $MIN_SUPPORTED_RUST_VERSION
allow_failures: $RUST_VERSION == 'nightly'
matrix:
- matrix:
- env:
TARGET: x86_64-unknown-linux-gnu
container:
image: rust:latest
<<: *base_linux
- env:
TARGET: x86_64-apple-darwin
osx_instance:
image: catalina-base
<<: *base_macos
- env:
TARGET: x86_64-unknown-freebsd
freebsd_instance:
image_family: freebsd-12-2
<<: *base_freebsd
<<: *install_target_unix
test_bin_script: cargo make test-bin "--target=$TARGET"
test_lib_script: cargo make test-lib "--target=$TARGET"
<<: *cleanup_before_upload_cache_unix
- env:
TARGET: x86_64-pc-windows-msvc
windows_container:
image: fnichol/windowsservercore:ltsc2019-vs2019-vctools
<<: *base_windows
<<: *install_target_windows
test_bin_script: cargo make test-bin "--target=$env:TARGET"
test_lib_script: cargo make test-lib "--target=$env:TARGET"
<<: *cleanup_before_upload_cache_windows
build_bin_task:
name: build-bin-${BIN}-${TARGET}.${EXT}
alias: build-bins
only_if:
$CIRRUS_TAG != '' || $CIRRUS_BRANCH == 'staging' || $CIRRUS_BRANCH ==
'trying'
env:
BIN: names
RUST_BACKTRACE: "1"
matrix:
- matrix:
- env:
matrix:
- TARGET: arm-unknown-linux-gnueabihf
STRIP: arm-linux-gnueabihf-strip
- TARGET: aarch64-unknown-linux-gnu
STRIP: aarch64-linux-gnu-strip
- TARGET: i686-unknown-linux-gnu
STRIP: x86_64-linux-gnu-strip
- TARGET: i686-unknown-linux-musl
STRIP: i686-linux-musl-strip
- TARGET: x86_64-unknown-linux-gnu
STRIP: strip
- TARGET: x86_64-unknown-linux-musl
STRIP: x86_64-linux-musl-strip
EXT: tar.gz
container:
image: rustembedded/cross:$TARGET
depends_on:
- check
- test-stable-x86_64-unknown-linux-gnu
<<: *base_linux
<<: *install_target_unix
<<: *build_bin_unix
archive_script: tar czf "$BIN-$TARGET.$EXT" "$BIN-$TARGET"
- env:
TARGET: x86_64-apple-darwin
STRIP: strip
EXT: zip
osx_instance:
image: catalina-base
depends_on:
- check
- test-stable-x86_64-apple-darwin
<<: *base_macos
<<: *install_target_unix
<<: *build_bin_unix
archive_script: zip "$BIN-$TARGET" "$BIN-$TARGET"
- env:
TARGET: x86_64-unknown-freebsd
STRIP: strip
EXT: tar.gz
freebsd_instance:
image_family: freebsd-12-2
depends_on:
- check
- test-stable-x86_64-unknown-freebsd
<<: *base_freebsd
<<: *install_target_unix
<<: *build_bin_unix
archive_script: tar czf "$BIN-$TARGET.$EXT" "$BIN-$TARGET"
checksums_script: ./.ci/build-checksums.sh "$BIN-$TARGET.$EXT"
binaries_artifacts:
path: "$BIN-$TARGET.$EXT*"
<<: *cleanup_before_upload_cache_unix
- env:
TARGET: x86_64-pc-windows-msvc
EXT: zip
windows_container:
image: fnichol/windowsservercore:ltsc2019-vs2019-vctools
depends_on:
- check
- test-stable-x86_64-pc-windows-msvc
<<: *base_windows
<<: *install_target_windows
<<: *build_bin_windows
archive_script: |
Compress-Archive "$env:BIN-$env:TARGET.exe" "$env:BIN-$env:TARGET.$env:EXT"
checksums_script:
.\.ci\build-checksums.ps1 "$env:BIN-$env:TARGET.$env:EXT"
binaries_artifacts:
path: "$BIN-$TARGET.$EXT*"
<<: *cleanup_before_upload_cache_windows
ci_finished_task:
name: ci-finished
depends_on:
- check
- tests
- build-bins
container:
image: alpine:3
clone_script: mkdir -p "$CIRRUS_WORKING_DIR"
success_script: /bin/true
create_github_release_task:
name: create-github-release
only_if: $CIRRUS_TAG != ''
depends_on:
- build-bins
container:
image: alpine:3
env:
BIN: names
GITHUB_TOKEN: ENCRYPTED[9be96903fa85656e590b3336e1a7d1f9c05ad5b1f1881acd47038451fc554f28568fc9a539617180cbd01d08d16f8d73]
install_dependencies_script: apk add curl git jo jq
create_github_release_script: |
if ! upload_url="$(
./.ci/cirrus-release.sh gh_create_version_release \
"$CIRRUS_REPO_FULL_NAME" \
"$CIRRUS_TAG"
)"; then
echo "xxx Failed to create release" >&2
exit 1
fi
echo "$upload_url" > /tmp/upload_url
download_cirrus_artifacts_script: |
cr="$(readlink -f ./.ci/cirrus-release.sh)"
manifest="$(readlink -f ".ci/$BIN.manifest.txt")"
mkdir -p /tmp/release
cd /tmp/release
awk '{ print $2 }' "$manifest" | while read -r a; do
"$cr" ci_download "build-bin-$a/binaries/$a"
"$cr" ci_download "build-bin-$a/binaries/$a.md5"
"$cr" ci_download "build-bin-$a/binaries/$a.sha256"
done
cp "$manifest" .
ls -l "$BIN"*
upload_github_release_artifacts_script: |
url="$(cat /tmp/upload_url)"
./.ci/cirrus-release.sh gh_upload_all "$url" /tmp/release
build_docker_image_docker_builder:
name: build-docker-image-${BIN}
alias: build-docker-images
only_if: $CIRRUS_TAG != ''
depends_on:
- build-bins
- create-github-release
env:
AUTHOR: Fletcher Nichol <fnichol@nichol.ca>
LICENSE: MIT
BIN: names
REPO: fnichol/$BIN
IMG: $REPO
TARGET: x86_64-unknown-linux-musl
EXT: tar.gz
ARCHIVE: $BIN-$TARGET.$EXT
DOCKER_USERNAME: ENCRYPTED[8a1752e5e975bfdb57a81e88dac08c6a31f909acd6a82e213b4d362a57f8b090767641662bab840d76ef26de38588451]
DOCKER_PASSWORD: ENCRYPTED[12bfff137d45a5dfb76671cbd072338ef04c54cf0f6b7076eccb8eaee28812e412c1eaacb612312a535b7b255ab18a93]
download_cirrus_artifacts_script: |
cr="$(readlink -f ./.ci/cirrus-release.sh)"
mkdir -p /tmp/artifacts
cd /tmp/artifacts
"$cr" ci_download "build-bin-$ARCHIVE/binaries/$ARCHIVE"
"$cr" ci_download "build-bin-$ARCHIVE/binaries/$ARCHIVE.sha256"
build_script: |
./.ci/build-docker-image.sh \
"$IMG" "${CIRRUS_TAG#v}" "$REPO" "$AUTHOR" "$LICENSE" "$BIN" \
"/tmp/artifacts/$ARCHIVE"
login_script: |
echo "$DOCKER_PASSWORD" \
| docker login --username "$DOCKER_USERNAME" --password-stdin
push_script: |
docker push "$IMG:${CIRRUS_TAG#v}"
if echo "${CIRRUS_TAG#v}" | grep -q -E '^\d+\.\d+.\d+$'; then
docker push "$IMG:latest"
fi
publish_crate_task:
name: publish-crate-${CRATE}
alias: publish-crates
only_if: $CIRRUS_TAG =~ 'v.*'
depends_on:
- create-github-release
- build-docker-images
env:
CRATE: names
CRATES_IO_TOKEN: ENCRYPTED[c3770979566d3fd0c7ba135250e2404db106867855055972b40c3ea37762a0ddc2115c03b1e97ad0de7ed9f99c2f0097]
container:
image: rust:latest
<<: *base_linux
login_script: echo "$CRATES_IO_TOKEN" | cargo login
publish_script: cargo publish
publish_github_release_task:
name: publish-github-release
only_if: $CIRRUS_TAG != ''
depends_on:
- create-github-release
- build-docker-images
- publish-crates
container:
image: alpine:3
env:
GITHUB_TOKEN: ENCRYPTED[9be96903fa85656e590b3336e1a7d1f9c05ad5b1f1881acd47038451fc554f28568fc9a539617180cbd01d08d16f8d73]
install_dependencies_script: apk add curl jo jq
publish_release_script: |
./.ci/cirrus-release.sh gh_publish_release \
"$CIRRUS_REPO_FULL_NAME" "$CIRRUS_TAG" CHANGELOG.md
release_finished_task:
name: release-finished
only_if: $CIRRUS_TAG != ''
depends_on:
- create-github-release
- build-docker-images
- publish-crates
- publish-github-release
container:
image: alpine:3
clone_script: mkdir -p "$CIRRUS_WORKING_DIR"
success_script: /bin/true
trigger_nightly_release_task:
name: trigger-nightly-release
only_if: $CIRRUS_CRON == 'nightly'
container:
image: alpine:3
env:
GITHUB_TOKEN: ENCRYPTED[9be96903fa85656e590b3336e1a7d1f9c05ad5b1f1881acd47038451fc554f28568fc9a539617180cbd01d08d16f8d73]
install_dependencies_script: apk add curl git jo jq
trigger_release_script:
./.ci/cirrus-release.sh gh_update_tag "$CIRRUS_REPO_FULL_NAME" nightly