forked from kubernetes-retired/kube-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·44 lines (37 loc) · 1.32 KB
/
build
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
#!/bin/bash
set -euo pipefail
COMMIT=$(git rev-parse HEAD)
TAG=$(git describe --exact-match --abbrev=0 --tags "${COMMIT}" 2> /dev/null || true)
BRANCH=$(git branch | grep \* | cut -d ' ' -f2 | sed -e 's/[^a-zA-Z0-9+=._:/-]*//g' || true)
OUTPUT_PATH=${OUTPUT_PATH:-"bin/kube-aws"}
VERSION=""
if [ -z "$TAG" ]; then
[[ -n "$BRANCH" ]] && VERSION="${BRANCH}/"
VERSION="${VERSION}${COMMIT:0:8}"
else
VERSION=$TAG
fi
# check for changed files (not untracked files)
if [ -n "$(git diff --shortstat 2> /dev/null | tail -n1)" ]; then
VERSION="${VERSION}+dirty"
fi
echo Building kube-aws ${VERSION}
printf 'Checking existence of the `packr` command that is used for embedding files into the resulting binary...'
if ! which packr 1>/dev/null; then
echo not found. installing...
go get -u github.com/gobuffalo/packr/packr
echo 'Installed `packr`.'
printf 'Ensuring that the installed command is available via PATH...'
export PATH=$PATH:$GOPATH/bin
echo 'done. PATH is now '"$PATH"
else
echo found. Skipped installation.
fi
packr -vz
if [[ ! "${BUILD_GOOS:-}" == "" ]];then
export GOOS=$BUILD_GOOS
fi
if [[ ! "${BUILD_GOARCH:-}" == "" ]];then
export GOARCH=$BUILD_GOARCH
fi
go build -ldflags "-X github.com/kubernetes-incubator/kube-aws/pkg/model.VERSION=${VERSION}" -a -tags netgo -installsuffix netgo -o "$OUTPUT_PATH" ./