fix dirty is not added in docker image tag

Signed-off-by: yingjinhui <yingjinhui@didiglobal.com>
This commit is contained in:
yingjinhui 2022-11-24 20:27:08 +08:00
parent 63a67d7cbd
commit d64d82c62f
4 changed files with 11 additions and 17 deletions

View File

@ -1,6 +1,6 @@
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
LDFLAGS='$(shell hack/version.sh)'
VERSION ?= '$(shell hack/version.sh)'
# Images management
REGISTRY?="docker.io/karmada"
@ -8,18 +8,6 @@ REGISTRY_USER_NAME?=""
REGISTRY_PASSWORD?=""
REGISTRY_SERVER_ADDRESS?=""
# Set your version by env or using latest tags from git
VERSION?=""
ifeq ($(VERSION), "")
LATEST_TAG=$(shell git describe --tags)
ifeq ($(LATEST_TAG),)
# Forked repo may not sync tags from upstream, so give it a default tag to make CI happy.
VERSION="unknown"
else
VERSION=$(LATEST_TAG)
endif
endif
TARGETS := karmada-aggregated-apiserver \
karmada-controller-manager \
karmada-scheduler \
@ -50,7 +38,7 @@ all: $(CMD_TARGET)
.PHONY: $(CMD_TARGET)
$(CMD_TARGET):
LDFLAGS=$(LDFLAGS) BUILD_PLATFORMS=$(GOOS)/$(GOARCH) hack/build.sh $@
BUILD_PLATFORMS=$(GOOS)/$(GOARCH) hack/build.sh $@
# Build image.
#

View File

@ -23,6 +23,8 @@ set -o pipefail
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${REPO_ROOT}/hack/util.sh"
LDFLAGS="$(util::version_ldflags) ${LDFLAGS:-}"
function build_binary() {
local -r target=$1

View File

@ -622,9 +622,13 @@ function util::get_macos_ipaddress() {
fi
}
function util::get_GO_LDFLAGS() {
function util::get_version() {
git describe --tags --dirty
}
function util::version_ldflags() {
# Git information
GIT_VERSION=$(git describe --tags --dirty)
GIT_VERSION=$(util::get_version)
GIT_COMMIT_HASH=$(git rev-parse HEAD)
if git_status=$(git status --porcelain 2>/dev/null) && [[ -z ${git_status} ]]; then
GIT_TREESTATE="clean"

View File

@ -7,4 +7,4 @@ set -o pipefail
KARMADA_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
source "${KARMADA_ROOT}/hack/util.sh"
util::get_GO_LDFLAGS
util::get_version