-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·43 lines (39 loc) · 1.13 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
#!/bin/bash
GIT_ORG_TAG=$(git describe --abbrev=0 --tags)
git describe --exact-match --abbrev=0 > /dev/null
if [ $? -ne 0 ];then
GIT_TAG="${GIT_ORG_TAG}-dirty"
BC_CMD=$(which bc)
if [ $? -ne 0 ];then
echo "!! Need bc command to calculate the number of commits since the latest tag -> proceed without..."
else
## commit since tags
CNT_ALL=$(git log --oneline |wc -l)
CNT_COMMITS=$(echo "${CNT_ALL}-$(git log --oneline ${GIT_ORG_TAG} |wc -l)" |bc)
if [ ${CNT_COMMITS} -ne 0 ];then
GIT_TAG="${GIT_TAG}-${CNT_COMMITS}"
else
GIT_TAG="${GIT_ORG_TAG}"
fi
fi
fi
if [ -f /etc/os-release ];then
. /etc/os-release
if [ "X${ID}" != "Xalpine" ];then
ID=Linux
fi
else
ID=$(uname -s)
fi
echo "> govendor fetch +missing"
govendor fetch +missing
echo "> govendor remove +unused"
govendor remove +unused
echo "> govendor update +local"
govendor update +local
#echo "> go get -d"
#go get -d
rm -f ./bin/qwatch_${GIT_TAG}_${ID}
go build -o ./bin/qwatch_${GIT_TAG}_${ID}
rm -f ./bin/qwatch_${ID}
cp ./bin/qwatch_${GIT_TAG}_${ID} ./bin/qwatch_${ID}