-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·43 lines (35 loc) · 871 Bytes
/
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/sh
set -e
PROJ="vault-kube"
ORG_PATH="github.com/sanjid133"
REPO_PATH="${ORG_PATH}/${PROJ}"
if ! [ -x "$(command -v go)" ]; then
echo "go is not installed"
exit 1
fi
if ! [ -x "$(command -v git)" ]; then
echo "git is not installed"
exit 1
fi
if [ -z "${GOPATH}" ]; then
echo "set GOPATH"
exit 1
fi
PATH="${PATH}:${GOPATH}/bin"
if [ -z "${VERSION}" ]; then
COMMIT=`git rev-parse --short HEAD`
TAG=$(git describe --exact-match --abbrev=0 --tags ${COMMIT} 2> /dev/null || true)
if [ -z "${TAG}" ]; then
VERSION=${COMMIT}
else
VERSION=${TAG}
fi
if [ -n "$(git diff --shortstat 2> /dev/null | tail -n1)" ]; then
VERSION="${VERSION}-dirty"
fi
fi
export GO111MODULE=on
go mod verify
go mod vendor
go fmt ./...
go install -v -ldflags="-X ${REPO_PATH}/version.Version=${VERSION}" ./cmd/...