Skip to content

Commit 5fdae23

Browse files
authored
[demos] Fix update demos [1.7.x] (#618)
* returning latest rc with same prefix. e.g. if 1.8.0+12345678 returns 1.8.0rcX * fix comparison to 1.7 for fetching properly demos assets
1 parent 919e709 commit 5fdae23

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

update_demos.sh

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,36 @@ get_latest_tag() {
251251
fi
252252
}
253253

254+
# --------------------------------------------------------------------------------------------------------------------------------
255+
# Function to get compare current version with 1.7 Iversion when demos were introduced
256+
# --------------------------------------------------------------------------------------------------------------------------------
257+
258+
is_newer_than_1_7() {
259+
version="${1#v}"
260+
base="${version%%-*}" # Strip -rcX if present
261+
rc="${version#"$base"}"
262+
263+
major=$(echo "$base" | cut -d. -f1)
264+
minor=$(echo "$base" | cut -d. -f2)
265+
major=${major:-0}
266+
minor=${minor:-0}
267+
268+
# If rc is present, consider version as pre-release → not >= 1.7
269+
if echo "$rc" | grep -q '^-' ; then
270+
# pre-release version like -rc2
271+
if [ "$major" -eq 1 ] && [ "$minor" -eq 7 ]; then
272+
return 1 # not considered >= 1.7
273+
fi
274+
fi
275+
276+
if [ "$major" -gt 1 ]; then return 0; fi
277+
if [ "$major" -eq 1 ] && [ "$minor" -gt 7 ]; then return 0; fi
278+
if [ "$major" -eq 1 ] && [ "$minor" -eq 7 ]; then return 0; fi
279+
280+
return 1
281+
}
282+
283+
254284
# --------------------------------------------------------------------------------------------------------------------------------
255285
# Download tar file to a temporary folder
256286
# --------------------------------------------------------------------------------------------------------------------------------
@@ -323,7 +353,7 @@ branch=${latest_tag#refs/tags/}
323353
echo "Using branch ${branch} to download demos"
324354
temp_dir=$(mktemp -d /tmp/temp-get-demos.XXXXXXXXXX)
325355
# demos introduced to mlrun in 1.7.0
326-
if [[ "${branch}">"v1.7" ]]; then
356+
if is_newer_than_1_7 "$branch"; then
327357
tar_url="${git_base_url}/releases/download/${branch}/mlrun-demos.tar"
328358
download_tar_to_temp_dir "$tar_url" "$temp_dir"
329359
verify_update_demos "${temp_dir}" "${branch}"

0 commit comments

Comments
 (0)