forked from maidsafe/autonomi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Justfile
382 lines (339 loc) · 10.1 KB
/
Justfile
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
#!/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
if [ -n "$MAX_CHUNK_SIZE" ]; then
echo "Overriding chunk size to $MAX_CHUNK_SIZE bytes"
fi
echo "================"
echo " Network Keys "
echo "================"
echo "FOUNDATION_PK: $FOUNDATION_PK"
echo "GENESIS_PK: $GENESIS_PK"
echo "NETWORK_ROYALTIES_PK: $NETWORK_ROYALTIES_PK"
echo "PAYMENT_FORWARD_PK: $PAYMENT_FORWARD_PK"
cross_container_opts="--env \"GENESIS_PK=$GENESIS_PK\" --env \"GENESIS_SK=$GENESIS_SK\" --env \"FOUNDATION_PK=$FOUNDATION_PK\" --env \"NETWORK_ROYALTIES_PK=$NETWORK_ROYALTIES_PK\" --env \"PAYMENT_FORWARD_PK=$PAYMENT_FORWARD_PK\""
export CROSS_CONTAINER_OPTS=$cross_container_opts
nightly_feature=""
if [[ "$nightly" == "true" ]]; then
nightly_feature="--features nightly"
fi
if [[ $arch == arm* || $arch == armv7* || $arch == aarch64* ]]; then
echo "Passing to cross CROSS_CONTAINER_OPTS=$CROSS_CONTAINER_OPTS"
cargo binstall --no-confirm cross
cross build --release --target $arch --bin nat-detection $nightly_feature
cross build --release --target $arch --bin node-launchpad $nightly_feature
cross build --release --features network-contacts,websockets --target $arch --bin autonomi $nightly_feature
cross build --release --features network-contacts,websockets --target $arch --bin antnode $nightly_feature
cross build --release --target $arch --bin antctl $nightly_feature
cross build --release --target $arch --bin antctld $nightly_feature
cross build --release --target $arch --bin antnode_rpc_client $nightly_feature
else
cargo build --release --target $arch --bin nat-detection $nightly_feature
cargo build --release --target $arch --bin node-launchpad $nightly_feature
cargo build --release --features network-contacts,websockets --target $arch --bin autonomi $nightly_feature
cargo build --release --features network-contacts,websockets --target $arch --bin antnode $nightly_feature
cargo build --release --target $arch --bin antctl $nightly_feature
cargo build --release --target $arch --bin antctld $nightly_feature
cargo build --release --target $arch --bin antnode_rpc_client $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 "autonomi"
just package-bin "antnode"
just package-bin "antctl"
just package-bin "antctld"
just package-bin "antnode_rpc_client"
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" \
"autonomi" \
"antnode" \
"antctl" \
"antctld" \
"antnode_rpc_client")
crate_dir_name=""
bin="{{bin}}"
case "$bin" in
nat-detection)
crate_dir_name="nat-detection"
;;
node-launchpad)
crate_dir_name="node-launchpad"
;;
autonomi)
crate_dir_name="autonomi-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"
;;
*)
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
autonomi
antnode
antctl
antnode_rpc_client
antctld
)
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"
;;
autonomi)
bucket="autonomi-cli"
;;
antnode)
bucket="antnode"
;;
antctl)
bucket="antctl"
;;
antctld)
bucket="antctld"
;;
antnode_rpc_client)
bucket="antnode-rpc-client"
;;
*)
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"
;;
autonomi)
bucket="autonomi-cli"
;;
antnode)
bucket="antnode"
;;
antctl)
bucket="antctl"
;;
antctld)
bucket="antctl"
;;
antnode_rpc_client)
bucket="antnode-rpc-client"
;;
*)
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
autonomi
antnode
antctl
antnode_rpc_client
antctld
)
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 ../../..