forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-server
executable file
·39 lines (30 loc) · 1.06 KB
/
build-server
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
#!/bin/bash
set -ex
source $(dirname $0)/version
source $(dirname $0)/export-config
cd $(dirname $0)/..
mkdir -p bin
if [ -n "${DEBUG}" ]; then
GCFLAGS="-N -l"
fi
if [ "$(uname)" != "Darwin" ]; then
LINKFLAGS="-extldflags -static"
if [ -z "${DEBUG}" ]; then
LINKFLAGS="${LINKFLAGS} -s"
fi
fi
RKE_VERSION="$(grep -m1 'github.com/rancher/rke' go.mod | awk '{print $2}')"
# Inject Setting values
DEFAULT_VALUES="{\"rke-version\":\"${RKE_VERSION}\"}"
CGO_ENABLED=0 go build -tags k8s \
-gcflags="all=${GCFLAGS}" \
-ldflags \
"-X github.com/rancher/rancher/pkg/version.Version=$VERSION
-X github.com/rancher/rancher/pkg/version.GitCommit=$COMMIT
-X github.com/rancher/rancher/pkg/settings.InjectDefaults=$DEFAULT_VALUES $LINKFLAGS" \
-o bin/rancher
if [ -n "$CATTLE_KDM_BRANCH" ]; then
curl -sLf https://releases.rancher.com/kontainer-driver-metadata/${CATTLE_KDM_BRANCH}/data.json > bin/data.json
elif [ ! -e bin/data.json ] && [ -e ../kontainer-driver-metadata/data/data.json ]; then
cp ../kontainer-driver-metadata/data/data.json bin/data.json
fi