Ver código fonte

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

also support tags like v5.1.1.1
Ivan Dyachkov 2 anos atrás
pai
commit
ff14995bf6
1 arquivos alterados com 22 adições e 2 exclusões
  1. 22 2
      scripts/parse-git-ref.sh

+ 22 - 2
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