-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathbuild-go.sh
executable file
·46 lines (34 loc) · 1.62 KB
/
build-go.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
#!/usr/bin/env bash
set -eu
REPO=github.com/openshift/cluster-version-operator
GOFLAGS=${GOFLAGS:--mod=vendor}
GLDFLAGS=${GLDFLAGS:-}
eval $(go env | grep -e "GOHOSTOS" -e "GOHOSTARCH")
GOOS=${GOOS:-${GOHOSTOS}}
GOARCH=${GOARCH:-${GOHOSTARCH}}
# Go to the root of the repo
cd "$(git rev-parse --show-cdup)"
VERSION_OVERRIDE=${VERSION_OVERRIDE:-${OS_GIT_VERSION:-}}
if [ -z "${VERSION_OVERRIDE:-}" ]; then
echo "Using version from git..."
VERSION_OVERRIDE=$(git describe --abbrev=8 --dirty --always)
fi
eval $(go env)
if [ -z ${BIN_PATH+a} ]; then
export BIN_PATH=_output/${GOOS}/${GOARCH}
fi
mkdir -p ${BIN_PATH}
# Build the openshift-tests-extension and compress it
echo "Building ${REPO} openshift-tests-extension binary (${VERSION_OVERRIDE})"
GO_COMPLIANCE_POLICY="exempt_all" CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} \
go build \
${GOFLAGS} \
-ldflags "${GLDFLAGS}" \
-o "${BIN_PATH}/openshift-tests-extension" \
"${REPO}/cmd/openshift-tests-extension/..."
echo "Compressing the openshift-tests-extension binary"
gzip --keep --force "${BIN_PATH}/openshift-tests-extension"
# Build the cluster-version-operator binary
GLDFLAGS+="-X ${REPO}/pkg/version.Raw=${VERSION_OVERRIDE}"
echo "Building ${REPO} cluster-version-operator binary (${VERSION_OVERRIDE})"
GOOS=${GOOS} GOARCH=${GOARCH} go build ${GOFLAGS} -ldflags "${GLDFLAGS}" -o ${BIN_PATH}/cluster-version-operator ${REPO}/cmd/cluster-version-operator/...