From 67bcbd988492239998012f380a89783ab6d63393 Mon Sep 17 00:00:00 2001 From: Pengfei Ni Date: Wed, 11 Aug 2021 16:29:40 +0800 Subject: [PATCH 1/2] fix: ensure major and minor versions are set correctly --- hack/pkg-config.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hack/pkg-config.sh b/hack/pkg-config.sh index 49b9857c55..d3ebef72e1 100755 --- a/hack/pkg-config.sh +++ b/hack/pkg-config.sh @@ -20,14 +20,25 @@ cd $(dirname "${BASH_SOURCE}")/.. if [ "${ENABLE_GIT_COMMAND}" = true ]; then GIT_VERSION=$(git describe --tags --always --abbrev=9 || echo) GIT_COMMIT=$(git rev-parse HEAD) + version_regex="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-([a-zA-Z0-9-]+)?$" + [[ "${GIT_VERSION}" =~ ${version_regex} ]] && { + # shellcheck disable=SC2034 + VERSION_MAJOR="${BASH_REMATCH[1]}" + # shellcheck disable=SC2034 + VERSION_MINOR="${BASH_REMATCH[2]}+" + } else GIT_VERSION="latest" GIT_COMMIT="latest" + VERSION_MAJOR="latest" + VERSION_MINOR="latest" fi VERSION_PKG=sigs.k8s.io/cloud-provider-azure/pkg/version LDFLAGS="-s -w" LDFLAGS="$LDFLAGS -X $VERSION_PKG.gitVersion=${GIT_VERSION}" LDFLAGS="$LDFLAGS -X $VERSION_PKG.gitCommit=${GIT_COMMIT}" +LDFLAGS="$LDFLAGS -X $VERSION_PKG.gitMajor=${VERSION_MAJOR}" +LDFLAGS="$LDFLAGS -X $VERSION_PKG.gitMinor=${VERSION_MINOR}" LDFLAGS="$LDFLAGS -X $VERSION_PKG.buildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" echo -ldflags \'$LDFLAGS\' From e71123e11cddb4db19132b7c9e4dcb4ed444c699 Mon Sep 17 00:00:00 2001 From: Pengfei Ni Date: Wed, 11 Aug 2021 16:38:27 +0800 Subject: [PATCH 2/2] fix: disable git for gcp cloud build --- cloudbuild.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 922aba20a2..387166d15b 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -7,13 +7,13 @@ timeout: 1200s options: substitution_option: ALLOW_LOOSE steps: - - name: "gcr.io/k8s-testimages/gcb-docker-gcloud:v20200713-e9b3d9d" + - name: "gcr.io/k8s-testimages/gcb-docker-gcloud:v20210722-085d930" entrypoint: make env: - TAG=${_GIT_TAG} - PULL_BASE_REF=${_PULL_BASE_REF} - PROJECT=${_STAGING_PROJECT} - - ENABLE_GIT_COMMAND=true + - ENABLE_GIT_COMMAND=false - DOCKER_CLI_EXPERIMENTAL=enabled - DOCKER_BUILDKIT=1 args: