forked from tair-opensource/RedisFullCheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·54 lines (43 loc) · 1.33 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
#!/usr/bin/env 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
# 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
info="main.VERSION=$branch"
# golang version
goversion=$(go version | awk -F' ' '{print $3;}')
info=$info","$goversion
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 "9" ]; then
echo "go version[$goversion] must >= 1.9"
exit 1
fi
t=$(date "+%Y-%m-%d_%H:%M:%S")
info=$info","$t
output=./bin/
rm -rf ${output}
echo "[ BUILD RELEASE ]"
run_builder='go build -v'
#goos=(windows darwin linux)
#for g in "${goos[@]}"; do
# export GOOS=$g
# echo "try build goos=$g"
# $run_builder -ldflags "-X $info" -o "$output/redis-full-check.$g" "./src/full_check/"
# echo "build successfully!"
#done
#echo "all build successfully!"
$run_builder -ldflags "-X $info" -o "$output/redis-full-check" "./src/full_check/"
echo "build successfully!"