Skip to content

Commit

Permalink
Merge pull request #511 from mlrun/1.5.x-dev
Browse files Browse the repository at this point in the history
1.5.x dev
  • Loading branch information
aviaIguazio authored Aug 25, 2023
2 parents 22041df + 0f475b2 commit 01be21e
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions update_demos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,39 @@ error_usage()
}

get_latest_tag() {
local mlrun_version="$1"
local git_owner="$2"
local git_repo="$3"
local git_base_url="$4"
local git_url="$5"

local tag_prefix=`echo ${mlrun_version} | cut -d . -f1-2`

# Fetch remote tags
local tags=$(git ls-remote --tags --refs --sort='v:refname' "${git_url}" "refs/tags/v${tag_prefix}.*")

# Extract tag names
local tag_names=$(echo "$tags" | awk -F'/' '{print $NF}')

# Find the latest release and RC
local latest_release=""
local latest_rc=""
for tag in $tag_names; do
if [[ $tag == *"rc"* ]]; then
latest_rc=$tag
else
latest_release=$tag
fi
done

if [[ -z $latest_release ]]; then
echo $latest_rc
else
echo $latest_release
fi
local mlrun_version="$1"
local git_owner="$2"
local git_repo="$3"
local git_base_url="$4" # Unused in this function but can be useful for future enhancements
local git_url="$5"

# Fetch tags from git
local tags=$(git ls-remote --tags --refs --sort='v:refname' "${git_url}" | awk '{print $2}')

local latest_release=""
local latest_rc=""

# Parse
while IFS= read -r tag; do
tag=${tag#refs/tags/}

# Check if tag matches the target
if [[ $tag =~ ^v${mlrun_version} ]]; then
if [[ $tag == *"-rc"* ]]; then
latest_rc=$tag
else
latest_release=$tag
fi
fi
done <<< "$tags"

if [[ -n "$latest_release" ]]; then
echo "$latest_release"
elif [[ -n "$latest_rc" ]]; then
echo "$latest_rc"
else
echo "No matching tags found."
fi
}

while :
Expand Down

0 comments on commit 01be21e

Please sign in to comment.