Skip to content

Commit 01be21e

Browse files
authored
Merge pull request #511 from mlrun/1.5.x-dev
1.5.x dev
2 parents 22041df + 0f475b2 commit 01be21e

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

update_demos.sh

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,39 @@ error_usage()
5050
}
5151

5252
get_latest_tag() {
53-
local mlrun_version="$1"
54-
local git_owner="$2"
55-
local git_repo="$3"
56-
local git_base_url="$4"
57-
local git_url="$5"
58-
59-
local tag_prefix=`echo ${mlrun_version} | cut -d . -f1-2`
60-
61-
# Fetch remote tags
62-
local tags=$(git ls-remote --tags --refs --sort='v:refname' "${git_url}" "refs/tags/v${tag_prefix}.*")
63-
64-
# Extract tag names
65-
local tag_names=$(echo "$tags" | awk -F'/' '{print $NF}')
66-
67-
# Find the latest release and RC
68-
local latest_release=""
69-
local latest_rc=""
70-
for tag in $tag_names; do
71-
if [[ $tag == *"rc"* ]]; then
72-
latest_rc=$tag
73-
else
74-
latest_release=$tag
75-
fi
76-
done
77-
78-
if [[ -z $latest_release ]]; then
79-
echo $latest_rc
80-
else
81-
echo $latest_release
82-
fi
53+
local mlrun_version="$1"
54+
local git_owner="$2"
55+
local git_repo="$3"
56+
local git_base_url="$4" # Unused in this function but can be useful for future enhancements
57+
local git_url="$5"
58+
59+
# Fetch tags from git
60+
local tags=$(git ls-remote --tags --refs --sort='v:refname' "${git_url}" | awk '{print $2}')
61+
62+
local latest_release=""
63+
local latest_rc=""
64+
65+
# Parse
66+
while IFS= read -r tag; do
67+
tag=${tag#refs/tags/}
68+
69+
# Check if tag matches the target
70+
if [[ $tag =~ ^v${mlrun_version} ]]; then
71+
if [[ $tag == *"-rc"* ]]; then
72+
latest_rc=$tag
73+
else
74+
latest_release=$tag
75+
fi
76+
fi
77+
done <<< "$tags"
78+
79+
if [[ -n "$latest_release" ]]; then
80+
echo "$latest_release"
81+
elif [[ -n "$latest_rc" ]]; then
82+
echo "$latest_rc"
83+
else
84+
echo "No matching tags found."
85+
fi
8386
}
8487

8588
while :

0 commit comments

Comments
 (0)