-
Notifications
You must be signed in to change notification settings - Fork 4
/
Justfile
103 lines (87 loc) · 2.7 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
#!/usr/bin/env just --justfile
release_repo := "maidsafe/antup"
build-release-artifacts arch:
#!/usr/bin/env bash
set -e
arch="{{arch}}"
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 install -y musl-tools
fi
rustup target add x86_64-unknown-linux-musl
fi
if [[ "$arch" == "x86_64-apple-darwin" || "$arch" == "aarch64-apple-darwin" ]]; then
rustup target add "$arch"
fi
rm -rf artifacts
mkdir artifacts
cargo clean
if [[ $arch == arm* || $arch == armv7* || $arch == aarch64* ]]; then
cargo install cross
cross build --release --target $arch --bin antup
else
cargo build --release --target $arch --bin antup
fi
find target/$arch/release -maxdepth 1 -type f -exec cp '{}' artifacts \;
rm -f artifacts/.cargo-lock
package-release-assets:
#!/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="antup"
version=$(cat Cargo.toml | grep "^version" | awk -F '=' '{ print $2 }' | xargs)
rm -rf deploy/$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 deploy/$bin
mv *.tar.gz deploy/$bin
mv *.zip deploy/$bin
upload-release-assets:
#!/usr/bin/env bash
set -e
version=$(cat Cargo.toml | grep "^version" | awk -F '=' '{ print $2 }' | xargs)
echo "Uploading assets to release..."
cd deploy/antup
ls | xargs gh release upload "v${version}" --repo {{release_repo}}
upload-release-assets-to-s3:
#!/usr/bin/env bash
set -e
cd deploy/antup
for file in *.zip *.tar.gz; do
aws s3 cp "$file" "s3://antup/$file" --acl public-read
done