-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·70 lines (54 loc) · 2.27 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
66
67
68
69
#!/bin/bash
BUILD_DATE=`date +%Y-%m-%d\ %H:%M`
VERSIONFILE="pkg/version/version.go"
VERSION="1.2.0"
if [ "$1" == "local" ] || [ "$1" == "docker" ]; then
if [ -e "$VERSIONFILE" ]; then
rm $VERSIONFILE
fi
mkdir -p pkg/version
echo "package version" > $VERSIONFILE
echo "const (" >> $VERSIONFILE
echo " VERSION = \"$VERSION \"" >> $VERSIONFILE
echo " BUILD_DATE = \"$BUILD_DATE\"" >> $VERSIONFILE
echo ")" >> $VERSIONFILE
# Check for --cache flag
args="$@"
replaced="${@/--cache/}"
if [ "$1" == "local" ] && [ "$args" == "$replaced" ]; then
echo "Fetching dependencies..."
glide install --strip-vendor
fi
COVERPKG=./cmd/server,./pkg/crypto,./pkg/etcd,./pkg/config,./pkg/email,./pkg/events,./pkg/kube,./pkg/middleware,./pkg/types,./pkg/validate
if [ "$1" == "local" ]; then
UNAME=$(uname)
if [ "$UNAME" == "Darwin" ]; then
OS="darwin"
elif [ "$UNAME" == "Linux" ]; then
OS="linux"
fi
echo Building apiserver-$OS-amd64
GOOS=$OS GOARCH=amd64 go build -o build/bin/apiserver-$OS-amd64 ./cmd/server
echo Building apictl-$OS-amd64
GOOS=$OS GOARCH=amd64 go build -o build/bin/ndslabsctl-$OS-amd64 ./cmd/apictl
if [ "$2" == "test" ]; then
echo Building test apiserver-$OS-amd64
GOOS=$OS GOARCH=amd64 go test -coverpkg=$COVERPKG -c -o build/bin/apiserver-$OS-amd64 ./cmd/server
fi
elif [ "$1" == "docker" ]; then
if [ "$2" == "test" ]; then
echo Building test apiserver-linux-amd64
GOOS=linux GOARCH=amd64 go test -coverpkg=$COVERPKG -c -o build/bin/apiserver-linux-amd64 ./cmd/server
else
echo Building apiserver-linux-amd64
GOOS=linux GOARCH=amd64 go build -o build/bin/apiserver-linux-amd64 ./cmd/server
fi
echo Building ndslabsctl-linux-amd64
GOOS=linux GOARCH=amd64 go build -o build/bin/ndslabsctl-linux-amd64 ./cmd/apictl
echo Building ndslabsctl-darwin-amd64
GOOS=darwin GOARCH=amd64 go build -o build/bin/ndslabsctl-darwin-amd64 ./cmd/apictl
fi
elif [ "$1" == "clean" ]; then
rm -r build
rm -r vendor/github.com vendor/golang.org vendor/gopkg.in vendor/k8s.io
fi