From 67ab1f6f334d2a0d3209ca4b55ad90c1994b00e5 Mon Sep 17 00:00:00 2001 From: Yuxiang Zhu Date: Wed, 15 Mar 2023 14:50:14 +0800 Subject: [PATCH] Fix empty component version Currently `git describe` is used to determine the component during OCP build. Since git tags may not be always applied, use environment variables instead. --- hack/go-build.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hack/go-build.sh b/hack/go-build.sh index 043dd3b2b..728e01c0e 100755 --- a/hack/go-build.sh +++ b/hack/go-build.sh @@ -15,8 +15,13 @@ eval $(go env | grep -e "GOHOSTOS" -e "GOHOSTARCH") cd "$(git rev-parse --show-cdup)" if [ -z ${VERSION_OVERRIDE+a} ]; then - echo "Using version from git..." - VERSION_OVERRIDE=$(git describe --abbrev=8 --dirty --always) + if [ -n "${BUILD_VERSION+a}" ] && [ -n "${BUILD_RELEASE+a}" ]; then + echo "Using version from the build system..." + VERSION_OVERRIDE="${BUILD_VERSION}-${BUILD_RELEASE}" + else + echo "Using version from git..." + VERSION_OVERRIDE=$(git describe --abbrev=8 --dirty --always) + fi fi GLDFLAGS+="-extldflags '-static' -X ${REPO}/pkg/version.Raw=${VERSION_OVERRIDE}"