-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_releases
executable file
·48 lines (37 loc) · 1.05 KB
/
build_releases
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
#!/usr/bin/env bash
package=$1
package_name=$2
if [[ -z "$package" ]]; then
echo "usage: $0 <package> <package_name>"
exit 1
fi
if [[ -z "$package_name" ]]; then
echo "usage: $0 <package> <package_name>"
exit 1
fi
platforms=("windows/amd64" "windows/386" "darwin/amd64" "darwin/arm64" "linux/arm64" "linux/amd64" "linux/386")
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
build_folder="build/${GOOS}-${GOARCH}"
mkdir -p ${build_folder}
output_name=$package_name
if [ $GOOS = "windows" ]; then
output_name+='.exe'
fi
env GOOS=$GOOS GOARCH=$GOARCH go build -o "${build_folder}/${output_name}" $package
if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution...'
exit 1
fi
cd ${build_folder}
cp ../../README.md .
if [ $GOOS = "windows" ]; then
zip -9 -y ${package_name}-${GOOS}-${GOARCH}.zip ${output_name} README.md
else
tar -czvf ${package_name}-${GOOS}-${GOARCH}.tar.gz ${output_name} README.md
fi
cd -
done