From ff14995bf694b5878665eb3c5fd9491af7dd54c3 Mon Sep 17 00:00:00 2001 From: Ivan Dyachkov Date: Fri, 4 Aug 2023 13:26:35 +0200 Subject: [PATCH] ci: automatically detect if the git tag is the latest one also support tags like v5.1.1.1 --- scripts/parse-git-ref.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/parse-git-ref.sh b/scripts/parse-git-ref.sh index a8d9fdf52..407c7b21a 100755 --- a/scripts/parse-git-ref.sh +++ b/scripts/parse-git-ref.sh @@ -4,16 +4,36 @@ set -euo pipefail # $1 is fully qualified git ref name, e.g. refs/tags/v5.1.0 or refs/heads/master +is_latest() { + ref_name=$(basename "$1") + latest_ref_name=$(git describe --tags "$(git rev-list --tags --max-count=1)") + if [[ "$ref_name" == "$latest_ref_name" ]]; then + echo true; + else + echo false; + fi +} + if [[ $1 =~ ^refs/tags/v[5-9]+\.[0-9]+\.[0-9]+$ ]]; then PROFILE=emqx EDITION=Opensource RELEASE=true - LATEST=true + LATEST=$(is_latest "$1") +elif [[ $1 =~ ^refs/tags/v[5-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + PROFILE=emqx + EDITION=Opensource + RELEASE=true + LATEST=$(is_latest "$1") elif [[ $1 =~ ^refs/tags/e[5-9]+\.[0-9]+\.[0-9]+$ ]]; then PROFILE=emqx-enterprise EDITION=Enterprise RELEASE=true - LATEST=true + LATEST=$(is_latest "$1") +elif [[ $1 =~ ^refs/tags/e[5-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + PROFILE=emqx-enterprise + EDITION=Enterprise + RELEASE=true + LATEST=$(is_latest "$1") elif [[ $1 =~ ^refs/tags/v[5-9]+\.[0-9]+\.[0-9]+-(alpha|beta|rc)\.[0-9]+$ ]]; then PROFILE=emqx EDITION=Opensource