-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.sh
executable file
·48 lines (40 loc) · 1.38 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
#!/bin/bash
set -e
rm -rf bin
mkdir -p bin/release
VERSION="1.1"
VERSION_HASH="$(git rev-parse --short HEAD)"
VERSION_DATE="$(date -u '+%d.%m.%Y %H:%M:%S')"
for goos in linux darwin windows ; do
for goarch in amd64 386; do
# path
outdir="bin/$goos/$goarch"
path="$outdir/obj-simplify"
if [ $goos = windows ] ; then
path=$path.exe
fi
# build
echo -e "\nBuilding $goos/$goarch"
GOOS=$goos GOARCH=$goarch go build -o $path -ldflags "-X 'main.Version=$VERSION' -X 'main.VersionHash=$VERSION_HASH' -X 'main.VersionDate=$VERSION_DATE'"
echo " > `du -hc $path | awk 'NR==1{print $1;}'` `file $path`"
# compress (for unique filenames to github release files)
if [ $goos = windows ] ; then
zip -rjX ./bin/release/$goos-$goarch.zip ./$outdir/ > /dev/null 2>&1
else
tar -C ./$outdir/ -cvzf ./bin/release/$goos-$goarch.tar.gz . > /dev/null 2>&1
fi
done
done
go env > .goenv
source .goenv
rm .goenv
echo -e "\nRelease done: $(./bin/$GOOS/$GOARCH/obj-simplify --version)"
for goos in linux darwin windows ; do
for goarch in amd64 386; do
path=bin/release/$goos-$goarch.tar.gz
if [ $goos = windows ] ; then
path=bin/release/$goos-$goarch.zip
fi
echo " > `du -hc $path | awk 'NR==1{print $1;}'` $path"
done
done