From 71ecce311ef58c44980f53711ffae6776786ac10 Mon Sep 17 00:00:00 2001 From: Yuxing Deng Date: Fri, 15 Dec 2023 16:08:48 +0800 Subject: [PATCH] fix(ci): add semver version for non-tag build --- hack/lib/version.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hack/lib/version.sh b/hack/lib/version.sh index cdf50536..6f41a65f 100755 --- a/hack/lib/version.sh +++ b/hack/lib/version.sh @@ -50,7 +50,7 @@ function autok3s::version::get_version_vars() { fi fi - if [[ -n ${GIT_VERSION:-} ]] || GIT_VERSION="$(git rev-parse --abbrev-ref HEAD | sed -E 's/[^a-zA-Z0-9]+/-/g' 2>/dev/null)"; then + if [[ -n ${GIT_VERSION:-} ]] || HEAD_TAG="$(git rev-parse --abbrev-ref HEAD | sed -E 's/[^a-zA-Z0-9]+/-/g' 2>/dev/null)"; then # check if the HEAD is tagged. if git_tag=$(git tag -l --contains HEAD | head -n 1 2>/dev/null) && [[ -n ${DRONE_TAG:-${git_tag}} ]]; then GIT_VERSION="${DRONE_TAG:-${git_tag}}" @@ -61,6 +61,8 @@ function autok3s::version::get_version_vars() { Current value is: ${GIT_VERSION} Please see more details here: https://semver.org" fi + else + GIT_VERSION="v0.0.0-$HEAD_TAG" fi # append suffix if the tree is dirty.