-
Notifications
You must be signed in to change notification settings - Fork 24
/
build.sh
executable file
·65 lines (54 loc) · 1.55 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
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -o errexit
# older version Git don't support --short !
if [ -d ".git" ];then
#branch=`git symbolic-ref --short -q HEAD`
branch=$(git symbolic-ref -q HEAD | awk -F'/' '{print $3;}')
cid=$(git rev-parse HEAD)
else
branch="unknown"
cid="0.0"
fi
branch=$branch","$cid
output=./bin/
rm -rf ${output}
mkdir ${output}
# make sure we're in the directory where the script lives
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
GOPATH=$(pwd)
export GOPATH
# golang version
goversion=$(go version | awk -F' ' '{print $3;}')
bigVersion=$(echo $goversion | awk -F'[o.]' '{print $2}')
midVersion=$(echo $goversion | awk -F'[o.]' '{print $3}')
if [ $bigVersion -lt "1" -o $bigVersion -eq "1" -a $midVersion -lt "6" ]; then
echo "go version[$goversion] must >= 1.6"
exit 1
fi
t=$(date "+%Y-%m-%d_%H:%M:%S")
echo "[ BUILD RELEASE ]"
run_builder='go build -v'
modules=(nimo-shake nimo-full-check)
#modules=(nimo-shake)
goos=(linux darwin)
for g in "${goos[@]}"; do
export GOOS=$g
export GOARCH=amd64
echo "try build goos=$g"
for i in "${modules[@]}" ; do
echo "build "$i
cd $i
info="$i/common.Version=$branch"
info=$info","$goversion
info=$info","$t
$run_builder -ldflags "-X $info" -o "${output}/$i.$g" "./main/main.go"
echo "build $i successfully!"
cd ..
cp "$i/${output}/$i.$g" ${output}/
done
echo "build goos=$g: all modules successfully!"
done
# copy scripts
cp scripts/start.sh ${output}/
cp scripts/stop.sh ${output}/