ci: automatically detect if the git tag is the latest one

also support tags like v5.1.1.1
This commit is contained in:
Ivan Dyachkov 2023-08-04 13:26:35 +02:00
parent 6093f03cb9
commit ff14995bf6
1 changed files with 22 additions and 2 deletions

View File

@ -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