-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·68 lines (55 loc) · 1.38 KB
/
build.sh
File metadata and controls
executable file
·68 lines (55 loc) · 1.38 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
#!/usr/bin/env bash
#
# Adapted from 'How To Build Go Executables for Multiple Platforms on Ubuntu 16.04'
# By Marko Mudrinić
#
# Usage:
# ./build.sh
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo "usage: $0"
echo "output: zipped executables to ./build directory"
fi
package=$1
if [[ -z "$package" ]]; then
package='gen3-client'
fi
package_split=(${package//\// })
package_name=${package_split[-1]}
platforms=(
"darwin/arm64"
"darwin/amd64"
"linux/amd64"
"windows/amd64"
)
mkdir -p ./build
> checksums.txt
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name=$package_name'-'$GOOS'-'$GOARCH
exe_name=$package_name
if [ $GOOS = "windows" ]; then
exe_name+='.exe'
elif [ $GOOS = "darwin" ]; then
if [ $GOARCH = "arm64" ]; then
output_name=$package_name'-macos'
elif [ $GOARCH = "amd64" ]; then
output_name=$package_name'-macos-intel'
fi
fi
printf 'Building %s...' "$output_name"
env GOOS=$GOOS GOARCH=$GOARCH go build -o ./build/$exe_name .
cd build
zip -r -q $output_name $exe_name
sha256sum $output_name.zip >> checksums.txt
cd ..
if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution...'
exit 1
fi
echo 'OK'
done
# Clean up build artifacts
rm build/{$package_name,$package_name.exe}