-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·36 lines (27 loc) · 1.08 KB
/
build.sh
File metadata and controls
executable file
·36 lines (27 loc) · 1.08 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
#!/usr/bin/env bash
set -e
release_path="$(pwd)/.release"
repo_name="$(grep '^module' go.mod |cut -d ' ' -f2 |rev |cut -d '/' -f1 |rev)"
targets=${@-"aix/ppc64 darwin/amd64 darwin/arm64 linux/amd64 linux/386 solaris/amd64 windows/amd64 windows/386"}
echo "----> Setting up Go repository"
rm -rf ${release_path}
mkdir -p ${release_path}
for target in $targets; do
os="$(echo $target | cut -d '/' -f1)"
arch="$(echo $target | cut -d '/' -f2)"
if [ "$os" = "windows" ]; then
output="${release_path}/${repo_name}_${os}_${arch}.exe"
else
output="${release_path}/${repo_name}_${os}_${arch}"
fi
echo "----> Building project for: $target"
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -o $output
zip -j $output.zip $output > /dev/null 2>&1
tar -czvf $output.tgz $output > /dev/null 2>&1
sha256sum $output |cut -d ' ' -f1 > $output-sha256sum.txt
sha256sum $output.zip |cut -d ' ' -f1 > $output-zip-sha256sum.txt
sha256sum $output.tgz |cut -d ' ' -f1 > $output-tgz-sha256sum.txt
done
echo "----> Build is complete. List of files at $release_path:"
cd $release_path
ls -al