-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild
More file actions
executable file
·52 lines (42 loc) · 920 Bytes
/
build
File metadata and controls
executable file
·52 lines (42 loc) · 920 Bytes
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
#!/bin/bash
BUILD_DATE=`date -u +'%Y-%m-%dT%H:%M:%SZ'`
echo "BUILD_DATE: $BUILD_DATE"
#
# set git build variables if git exists
if git status 2>&1 > /dev/null;
then
if [ -z $GIT_COMMIT ];
then
GIT_COMMIT=`git rev-parse --short HEAD`
fi
if [ -z $GIT_BRANCH ];
then
GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
fi
if [ -z $VERSION ];
then
VERSION=`git tag --points-at $GIT_COMMIT | head -n 1`
fi
fi
if [ -z $GIT_COMMIT ];
then
GIT_COMMIT="dev"
fi
echo "GIT_COMMIT: $GIT_COMMIT"
if [ -z $GIT_BRANCH ];
then
GIT_BRANCH="dev"
fi
echo "GIT_BRANCH: $GIT_BRANCH"
if [ ! -z $VERSION ];
then
echo "VERSION: $VERSION"
fi
export CGO_ENABLED=0
go build -ldflags "
-s -w
-X 'main.version=$VERSION'
-X 'main.buildDate=$BUILD_DATE'
-X 'main.gitCommit=$GIT_COMMIT'
-X 'main.gitBranch=$GIT_BRANCH'
" -o bin main.go