-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·130 lines (99 loc) · 2.82 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
set -e
# build.sh
OSNAME="$1"
if [ "$OSNAME" == "help" ]; then
echo "Build NRT"
echo " - Requirements:"
echo " . Access to nsip github"
echo " . go - version 1.16 or above"
echo " . Utilities - git, zip, unzip, curl"
echo " - NRT version is detected using tools/release and tags, taken from nsip github"
echo " - OS is auto detect, or can be provided:"
echo " . Linux64"
echo " . Mac"
echo " . Windows64"
echo ""
exit 1
fi
DEPENDS=("git" "zip" "unzip" "curl")
for b in ${DEPENDS[@]}; do
if ! [ -x "$(command -v $b)" ]; then
echo "Missing utilitiy: $b"
exit 1
fi
done
ruby version.rb > cmd/nrt/version.go
go get gopkg.in/cheggaaa/pb.v1
cd tools; go build release.go; cd ..
VERSION="$(./tools/release dev-nrt version)"
if [ -z "$VERSION" ]; then
echo "Cannot determine version from repo."
exit 1
fi
echo "NRT-BUILD: VERSION=$VERSION"
# Specific branches
# NRT_BRANCH="master" # always for formal release
NRT_BRANCH="add-splitter" # for testing/alphas etc.
ORIGINALPATH=`pwd`
GOARCH=amd64
LDFLAGS="-s -w"
export GOARCH
# Simplified - assumes all 64 bit for now
if [ "$OSNAME" == "" ]; then
case "$OSTYPE" in
linux*) OSNAME="Linux64" ;;
Linux*) OSNAME="Linux64" ;;
darwin*) OSNAME="Mac" ;;
Darwin*) OSNAME="Mac" ;;
win*) OSNAME="Windows64" ;;
Win*) OSNAME="Windows64" ;;
esac
fi
if [ "$OSNAME" == "" ]; then
echo "Unknown operating system from $OSTYPE"
exit 1
fi
GOOS=""
case "$OSNAME" in
Linux64) GOOS="linux" ;;
Mac) GOOS="darwin" ;;
Windows64) GOOS="windows" ;;
esac
export GOOS
EXT=""
case "$OSNAME" in
Windows64) EXT=".exe" ;;
esac
# creates a all build of the NRT components and combined into
# ZIP files for release.
echo "NRT-BUILD: Start - Building NRT-$OSNAME-$VERSION"
echo "NRT-BUILD NOTE: removing existing builds"
rm -rf build
mkdir -p build
# echo "NRTBUILD: Static Code"
cd "$ORIGINALPATH"
echo "NRT-BUILD: Creating NRT @ $NRT_BRANCH"
cd cmd/nrt
echo "NRT-BUILD: building NRT application"
go build -ldflags="$LDFLAGS"
# copy supporting files
rsync -av * "$ORIGINALPATH"/build/
rsync -av config "$ORIGINALPATH"/build/
rsync -av config_split "$ORIGINALPATH"/build/
# remove golang files copied
rm "$ORIGINALPATH"/build/main.go || true
rm "$ORIGINALPATH"/build/version.go || true
# include test data samples in distribution
cd "$ORIGINALPATH"
rsync -av testdata "$ORIGINALPATH"/build/
# include this project readme as minimal documentation
echo "NRT-BUILD: Documentation"
cp README.md build/
echo "NRT-BUILD: Generating ZIP"
cd build
rm ../NRT-$OSNAME-$VERSION.zip || true
zip -qr ../NRT-$OSNAME-$VERSION.zip *
echo "NRT-BUILD: Complete - NRT-$OSNAME-$VERSION.zip"
echo "If happy with zip, run the following release command"
echo " ./tools/release dev-nrt NRT-$OSNAME.zip NRT-$OSNAME-$VERSION.zip"