forked from maidsafe/autonomi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
512 lines (451 loc) · 11.8 KB
/
Justfile
File metadata and controls
512 lines (451 loc) · 11.8 KB
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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
#!/usr/bin/env just --justfile
build-release-artifacts arch nightly="false":
#!/usr/bin/env bash
set -e
arch="{{arch}}"
nightly="{{nightly}}"
supported_archs=(
"x86_64-pc-windows-msvc"
"x86_64-apple-darwin"
"aarch64-apple-darwin"
"x86_64-unknown-linux-musl"
"arm-unknown-linux-musleabi"
"armv7-unknown-linux-musleabihf"
"aarch64-unknown-linux-musl"
)
arch_supported=false
for supported_arch in "${supported_archs[@]}"; do
if [[ "$arch" == "$supported_arch" ]]; then
arch_supported=true
break
fi
done
if [[ "$arch_supported" == "false" ]]; then
echo "$arch is not supported."
exit 1
fi
if [[ "$arch" == "x86_64-unknown-linux-musl" ]]; then
if [[ "$(grep -E '^NAME="Ubuntu"' /etc/os-release)" ]]; then
# This is intended for use on a fresh Github Actions agent
sudo apt update -y
sudo apt-get install -y musl-tools
fi
fi
rustup target add {{arch}}
rm -rf artifacts
mkdir artifacts
cargo clean
nightly_feature=""
if [[ "$nightly" == "true" ]]; then
nightly_feature="--features nightly"
fi
if [[ $arch == arm* || $arch == armv7* || $arch == aarch64* ]]; then
cargo binstall --no-confirm cross
build_cmd="cross build --release --target $arch"
else
build_cmd="cargo build --release --target $arch"
fi
if [[ "${BUILD_NAT_DETECTION:-true}" == "true" ]]; then
$build_cmd --bin nat-detection $nightly_feature
fi
if [[ "${BUILD_NODE_LAUNCHPAD:-true}" == "true" ]]; then
$build_cmd --bin node-launchpad $nightly_feature
fi
if [[ "${BUILD_ANT:-true}" == "true" ]]; then
$build_cmd --bin ant $nightly_feature --features loud
fi
if [[ "${BUILD_ANTNODE:-true}" == "true" ]]; then
$build_cmd --bin antnode $nightly_feature
fi
if [[ "${BUILD_ANTCTL:-true}" == "true" ]]; then
$build_cmd --bin antctl $nightly_feature
fi
if [[ "${BUILD_ANTCTLD:-true}" == "true" ]]; then
$build_cmd --bin antctld $nightly_feature
fi
if [[ "${BUILD_ANTNODE_RPC_CLIENT:-true}" == "true" ]]; then
$build_cmd --bin antnode_rpc_client $nightly_feature
fi
if [[ "${BUILD_EVM_TESTNET:-true}" == "true" ]]; then
$build_cmd --bin evm-testnet $nightly_feature
fi
find target/$arch/release -maxdepth 1 -type f -exec cp '{}' artifacts \;
rm -f artifacts/.cargo-lock
# Debugging target that builds an `artifacts` directory to be used with packaging targets.
#
# To use, download the artifact zip files from the workflow run and put them in an `artifacts`
# directory here. Then run the target.
make-artifacts-directory:
#!/usr/bin/env bash
set -e
architectures=(
"x86_64-pc-windows-msvc"
"x86_64-apple-darwin"
"aarch64-apple-darwin"
"x86_64-unknown-linux-musl"
"arm-unknown-linux-musleabi"
"armv7-unknown-linux-musleabihf"
"aarch64-unknown-linux-musl"
)
cd artifacts
for arch in "${architectures[@]}" ; do
mkdir -p $arch/release
unzip autonomi-$arch.zip -d $arch/release
rm autonomi-$arch.zip
done
package-all-bins:
#!/usr/bin/env bash
set -e
just package-bin "nat-detection"
just package-bin "node-launchpad"
just package-bin "ant"
just package-bin "antnode"
just package-bin "antctl"
just package-bin "antctld"
just package-bin "antnode_rpc_client"
just package-bin "evm-testnet"
package-bin bin version="":
#!/usr/bin/env bash
set -e
architectures=(
"x86_64-pc-windows-msvc"
"x86_64-apple-darwin"
"aarch64-apple-darwin"
"x86_64-unknown-linux-musl"
"arm-unknown-linux-musleabi"
"armv7-unknown-linux-musleabihf"
"aarch64-unknown-linux-musl"
)
bin="{{bin}}"
supported_bins=(\
"nat-detection" \
"node-launchpad" \
"ant" \
"antnode" \
"antctl" \
"antctld" \
"antnode_rpc_client" \
"evm-testnet")
crate_dir_name=""
bin="{{bin}}"
case "$bin" in
nat-detection)
crate_dir_name="nat-detection"
;;
node-launchpad)
crate_dir_name="node-launchpad"
;;
ant)
crate_dir_name="ant-cli"
;;
antnode)
crate_dir_name="ant-node"
;;
antctl)
crate_dir_name="ant-node-manager"
;;
antctld)
crate_dir_name="ant-node-manager"
;;
antnode_rpc_client)
crate_dir_name="ant-node-rpc-client"
;;
evm-testnet)
crate_dir_name="evm-testnet"
;;
*)
echo "The $bin binary is not supported"
exit 1
;;
esac
if [[ -z "{{version}}" ]]; then
version=$(grep "^version" < $crate_dir_name/Cargo.toml | \
head -n 1 | awk '{ print $3 }' | sed 's/\"//g')
else
version="{{version}}"
fi
if [[ -z "$version" ]]; then
echo "Error packaging $bin. The version number was not retrieved."
exit 1
fi
rm -rf packaged_bins/$bin
find artifacts/ -name "$bin" -exec chmod +x '{}' \;
for arch in "${architectures[@]}" ; do
echo "Packaging for $arch..."
if [[ $arch == *"windows"* ]]; then bin_name="${bin}.exe"; else bin_name=$bin; fi
zip -j $bin-$version-$arch.zip artifacts/$arch/release/$bin_name
tar -C artifacts/$arch/release -zcvf $bin-$version-$arch.tar.gz $bin_name
done
mkdir -p packaged_bins/$bin
mv *.tar.gz packaged_bins/$bin
mv *.zip packaged_bins/$bin
upload-all-packaged-bins-to-s3:
#!/usr/bin/env bash
set -e
binaries=(
nat-detection
node-launchpad
ant
antnode
antctl
antnode_rpc_client
antctld
evm-testnet
)
for binary in "${binaries[@]}"; do
just upload-packaged-bin-to-s3 "$binary"
done
upload-packaged-bin-to-s3 bin_name:
#!/usr/bin/env bash
set -e
case "{{bin_name}}" in
nat-detection)
bucket="nat-detection"
;;
node-launchpad)
bucket="node-launchpad"
;;
ant)
bucket="autonomi-cli"
;;
antnode)
bucket="antnode"
;;
antctl)
bucket="antctl"
;;
antctld)
bucket="antctl"
;;
antnode_rpc_client)
bucket="antnode-rpc-client"
;;
evm-testnet)
bucket="evm-testnet"
;;
*)
echo "The {{bin_name}} binary is not supported"
exit 1
;;
esac
cd packaged_bins/{{bin_name}}
for file in *.zip *.tar.gz; do
dest="s3://$bucket/$file"
if [[ "$file" == *latest* ]]; then
echo "Allowing overwrite for 'latest' version..."
aws s3 cp "$file" "$dest" --acl public-read
else
if aws s3 ls "$dest" > /dev/null 2>&1; then
echo "$dest already exists. Will not overwrite."
else
# This command outputs a lot text which makes the build log difficult to read, so we will
# suppress it.
aws s3 cp "$file" "$dest" --acl public-read > /dev/null 2>&1
echo "$dest uploaded"
fi
fi
done
delete-s3-bin bin_name version:
#!/usr/bin/env bash
set -e
case "{{bin_name}}" in
nat-detection)
bucket="nat-detection"
;;
node-launchpad)
bucket="node-launchpad"
;;
ant)
bucket="autonomi-cli"
;;
antnode)
bucket="antnode"
;;
antctl)
bucket="antctl"
;;
antctld)
bucket="antctl"
;;
antnode_rpc_client)
bucket="antnode-rpc-client"
;;
evm-testnet)
bucket="evm-testnet"
;;
*)
echo "The {{bin_name}} binary is not supported"
exit 1
;;
esac
architectures=(
"x86_64-pc-windows-msvc"
"x86_64-apple-darwin"
"aarch64-apple-darwin"
"x86_64-unknown-linux-musl"
"arm-unknown-linux-musleabi"
"armv7-unknown-linux-musleabihf"
"aarch64-unknown-linux-musl"
)
for arch in "${architectures[@]}"; do
zip_filename="{{bin_name}}-{{version}}-${arch}.zip"
tar_filename="{{bin_name}}-{{version}}-${arch}.tar.gz"
s3_zip_path="s3://$bucket/$zip_filename"
s3_tar_path="s3://$bucket/$tar_filename"
aws s3 rm "$s3_zip_path"
echo "deleted $s3_zip_path"
aws s3 rm "$s3_tar_path"
echo "deleted $s3_tar_path"
done
package-all-architectures:
#!/usr/bin/env bash
set -e
architectures=(
"x86_64-pc-windows-msvc"
"x86_64-apple-darwin"
"aarch64-apple-darwin"
"x86_64-unknown-linux-musl"
"arm-unknown-linux-musleabi"
"armv7-unknown-linux-musleabihf"
"aarch64-unknown-linux-musl"
)
rm -rf packaged_architectures
for arch in "${architectures[@]}" ; do
echo "Packaging artifacts for $arch..."
just package-arch "$arch"
done
package-arch arch:
#!/usr/bin/env bash
set -e
if [[ -n $PACKAGE_VERSION ]]; then
version="$PACKAGE_VERSION"
else
release_year=$(grep 'release-year:' release-cycle-info | awk '{print $2}')
release_month=$(grep 'release-month:' release-cycle-info | awk '{print $2}')
release_cycle=$(grep 'release-cycle:' release-cycle-info | awk '{print $2}')
release_cycle_counter=$(grep 'release-cycle-counter:' release-cycle-info | awk '{print $2}')
version="$release_year.$release_month.$release_cycle.$release_cycle_counter"
fi
architecture="{{arch}}"
zip_filename="${version}.autonomi.${architecture}.zip"
mkdir -p packaged_architectures
cd artifacts/$architecture/release
binaries=(
nat-detection
node-launchpad
ant
antnode
antctl
antnode_rpc_client
antctld
evm-testnet
)
if [[ "$architecture" == *"windows"* ]]; then
for binary in "${binaries[@]}"; do
binaries_with_extension+=("$binary.exe")
done
zip "../../../packaged_architectures/$zip_filename" "${binaries_with_extension[@]}"
else
zip "../../../packaged_architectures/$zip_filename" "${binaries[@]}"
fi
cd ../../..
build-artifact-hashes:
#!/usr/bin/env bash
set -e
architectures=(
"x86_64-pc-windows-msvc"
"x86_64-apple-darwin"
"aarch64-apple-darwin"
"x86_64-unknown-linux-musl"
"arm-unknown-linux-musleabi"
"armv7-unknown-linux-musleabihf"
"aarch64-unknown-linux-musl"
)
binaries=(
"nat-detection"
"node-launchpad"
"ant"
"antnode"
"antctl"
"antctld"
"antnode_rpc_client"
"evm-testnet"
)
echo "## Binary Hashes"
echo ""
for arch in "${architectures[@]}"; do
echo "### $arch"
echo ""
echo "| Binary | SHA256 Hash |"
echo "|--------|-------------|"
for binary in "${binaries[@]}"; do
if [[ "$arch" == *"windows"* ]]; then
binary_path="artifacts/$arch/release/${binary}.exe"
else
binary_path="artifacts/$arch/release/${binary}"
fi
if [[ -f "$binary_path" ]]; then
hash=$(sha256sum "$binary_path" | awk '{print $1}')
echo "| $binary | \`$hash\` |"
else
echo "| $binary | *not found* |"
fi
done
done
build-binary-versions:
#!/usr/bin/env bash
set -e
binaries=(
"antnode"
"antctl"
"antctld"
"ant"
"evm-testnet"
"nat-detection"
"node-launchpad"
)
echo "## Binary Versions"
echo ""
for binary in "${binaries[@]}"; do
# Map binary name to crate directory name
case "$binary" in
nat-detection)
crate_dir_name="nat-detection"
;;
node-launchpad)
crate_dir_name="node-launchpad"
;;
ant)
crate_dir_name="ant-cli"
;;
antnode)
crate_dir_name="ant-node"
;;
antctl)
crate_dir_name="ant-node-manager"
;;
antctld)
crate_dir_name="ant-node-manager"
;;
antnode_rpc_client)
crate_dir_name="ant-node-rpc-client"
;;
evm-testnet)
crate_dir_name="evm-testnet"
;;
*)
echo "Error: Unknown binary $binary" >&2
exit 1
;;
esac
version=$(grep "^version" < $crate_dir_name/Cargo.toml | \
head -n 1 | awk '{ print $3 }' | sed 's/\"//g')
if [[ -z "$version" ]]; then
echo "Error: Could not extract version for $binary from $crate_dir_name/Cargo.toml" >&2
exit 1
fi
# Ensure version has 'v' prefix
[[ ! "$version" =~ ^v ]] && version="v$version"
echo "* \`$binary\`: $version"
done
echo ""