From 1b39f809f5d4dfa2d12d66625d862d516a52e6b8 Mon Sep 17 00:00:00 2001 From: pvincent Date: Tue, 4 Jan 2022 07:32:18 +0400 Subject: [PATCH] github release compare v and non-v tags --- tools/wget_semver | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/wget_semver b/tools/wget_semver index f157662..d0705f3 100755 --- a/tools/wget_semver +++ b/tools/wget_semver @@ -15,18 +15,22 @@ function usage() { } function get_github() { - local all_releases=$(git ls-remote --tags --sort="v:refname" git://github.com/$REPO_NAME | grep -Eo "v?([0-9]\.)+[0-9]+") + local all_releases=$(git ls-remote --tags --sort="v:refname" git://github.com/"$REPO_NAME" | grep -Eo "v?([0-9]+\.){2}[0-9]+$" ) # extract only VERSION without 'v' - local non_v_release=$(echo "$all_releases" | - grep -v "refs/tags/v" | grep -v v | tail -n1 | cut -f2 | cut -d '/' -f3) + local non_v_release=$(echo "$all_releases" | grep -v v | tail -n1 | cut -f2 | cut -d '/' -f3) non_v_release=${non_v_release%^\{\}} # remove extra characters ^{} from github - [ -n "$non_v_release" ] && echo $non_v_release && return # extract remaining version including 'v' local v_release=$(echo "$all_releases" | tail -n1 | cut -f2 | cut -d '/' -f3) v_release=${v_release%^\{\}} # remove extra characters ^{} from github - echo $v_release + + # compare which newer from non_v_release to v_release + if [ -n "$non_v_release" ] && [ "v$non_v_release" \> "$v_release" ]; then + echo $non_v_release + else + echo $v_release + fi } function get_artcode() {