From 654aa9bfacdd76149c67b601bc926607b668c42f Mon Sep 17 00:00:00 2001
From: paulfantom <pawel@krupa.net.pl>
Date: Tue, 29 Jun 2021 10:08:20 +0200
Subject: [PATCH] scripts: use newer version when generating

---
 scripts/generate-versions.sh | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/scripts/generate-versions.sh b/scripts/generate-versions.sh
index c20a1881..05c48a63 100755
--- a/scripts/generate-versions.sh
+++ b/scripts/generate-versions.sh
@@ -23,12 +23,19 @@ get_current_version() {
 get_version() {
   component="${1}"
   v="$(get_latest_version "${component}")"
- 
+
+  component="$(convert_to_camel_case "$(echo "${component}" | sed 's/^.*\///')")"
+  cv="$(get_current_version "${component}")"
+
   # Advanced AI heurestics to filter out common patterns suggesting new version is not stable /s
   if [[ "$v" == "" ]] || [[ "$v" == *"alpha"* ]] || [[ "$v" == *"beta"* ]] || [[ "$v" == *"rc"* ]] || [[ "$v" == *"helm"* ]]; then
-     component="$(convert_to_camel_case "$(echo "${component}" | sed 's/^.*\///')")"
-     v="$(get_current_version "${component}")"
+     echo "$cv"
+     return
   fi
+
+  # Use higher version from new version and current version
+  v=$(printf '%s\n' "$v" "$cv" | sort -r | head -n1)
+  
   echo "$v"
 }
 
-- 
GitLab