1
0
mirror of https://github.com/openshift/installer.git synced 2026-02-05 15:47:14 +01:00
Files
installer/hack/build-node-joiner.sh
2025-01-24 13:31:46 -08:00

56 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
set -ex
# shellcheck disable=SC2068
version() { IFS="."; printf "%03d%03d%03d\\n" $@; unset IFS;}
minimum_go_version=1.23
current_go_version=$(go version | cut -d " " -f 3)
if [ "$(version "${current_go_version#go}")" -lt "$(version "$minimum_go_version")" ]; then
echo "Go version should be greater or equal to $minimum_go_version"
exit 1
fi
export CGO_ENABLED=0
MODE="${MODE:-release}"
GIT_COMMIT="${SOURCE_GIT_COMMIT:-$(git rev-parse --verify 'HEAD^{commit}')}"
GIT_TAG="${BUILD_VERSION:-$(git describe --always --abbrev=40 --dirty)}"
DEFAULT_ARCH="${DEFAULT_ARCH:-amd64}"
GOFLAGS="${GOFLAGS:--mod=vendor}"
GCFLAGS=""
LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/version.Raw=${GIT_TAG} -X github.com/openshift/installer/pkg/version.Commit=${GIT_COMMIT} -X github.com/openshift/installer/pkg/version.defaultArch=${DEFAULT_ARCH}"
TAGS="${TAGS:-}"
OUTPUT="${OUTPUT:-bin/node-joiner}"
case "${MODE}" in
release)
LDFLAGS="${LDFLAGS} -s -w"
TAGS="${TAGS} release"
;;
dev)
GCFLAGS="${GCFLAGS} all=-N -l"
;;
*)
echo "unrecognized mode: ${MODE}" >&2
exit 1
esac
if test "${SKIP_GENERATION}" != y
then
# this step has to be run natively, even when cross-compiling
GOOS='' GOARCH='' go generate ./data
fi
if (echo "${TAGS}" | grep -q '\bfipscapable\b')
then
export CGO_ENABLED=1
fi
echo "building node-joiner"
# shellcheck disable=SC2086
go build ${GOFLAGS} -gcflags "${GCFLAGS}" -ldflags "${LDFLAGS}" -tags "${TAGS}" -o "${OUTPUT}" ./cmd/node-joiner