-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·54 lines (52 loc) · 1.1 KB
/
build.sh
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
package="goaround"
platforms=("darwin/amd64"
"darwin/arm64"
"dragonfly/amd64"
"freebsd/386"
"freebsd/amd64"
"freebsd/arm"
"freebsd/arm64"
"illumos/amd64"
"linux/386"
"linux/amd64"
"linux/arm"
"linux/arm64"
"netbsd/386"
"netbsd/amd64"
"netbsd/arm"
"netbsd/arm64"
"openbsd/386"
"openbsd/amd64"
"openbsd/arm"
"openbsd/arm64"
"openbsd/mips64"
"plan9/386"
"plan9/amd64"
"plan9/arm"
"solaris/amd64"
"windows/386"
"windows/amd64"
"windows/arm"
"windows/arm64")
version="0.8"
package_split=(${package//\// })
package_name=${package_split[-1]}
for platform in "${platforms[@]}"
do
bin_name=$package_name
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
if [ $GOOS = "windows" ]; then
bin_name+='.exe'
fi
env GOOS=$GOOS GOARCH=$GOARCH go build -o $bin_name main.go
if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution...'
exit 1
fi
output_name=$package_name'-v'$version'-'$GOOS'-'$GOARCH.tar.gz
tar -czvf 'dist/'$output_name $bin_name
echo "Package $output_name is created."
rm $bin_name
done