diff --git a/bin/latest-stable b/bin/latest-stable index 818f26e..ebdfd08 100755 --- a/bin/latest-stable +++ b/bin/latest-stable @@ -21,7 +21,7 @@ redirect_url=$(curl "${curl_opts[@]}" "$GH_REPO/releases/latest" | sed -n -e "s| version= printf "redirect url: %s\n" "$redirect_url" >&2 if [[ "$redirect_url" == "$GH_REPO/releases" ]]; then - version="$(list_all_versions | sort_versions | tail -n1 | xargs echo)" + version="$(list_all_versions_sorted | tail -n1 | xargs echo)" else version="$(printf "%s\n" "$redirect_url" | sed 's|.*/tag/v\{0,1\}||')" fi diff --git a/bin/list-all b/bin/list-all index 9b8b666..252803f 100755 --- a/bin/list-all +++ b/bin/list-all @@ -8,4 +8,4 @@ plugin_dir=$(dirname "$(dirname "$current_script_path")") # shellcheck source=./lib/utils.bash source "${plugin_dir}/lib/utils.bash" -list_all_versions | sort_versions | xargs echo +list_all_versions_sorted | xargs echo diff --git a/lib/utils.bash b/lib/utils.bash index 2e3ed8f..6a9cb3a 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -17,21 +17,16 @@ if [ -n "${GITHUB_API_TOKEN:-}" ]; then curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN") fi -sort_versions() { - sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | - LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}' -} - -list_github_tags() { - git ls-remote --tags --refs "$GH_REPO" | +list_github_tags_sorted() { + git -c 'versionsort.suffix=-beta' ls-remote --tags --refs --sort version:refname "$GH_REPO" | grep -o 'refs/tags/.*' | cut -d/ -f3- | sed 's/^v//' # NOTE: You might want to adapt this sed to remove non-version strings from tags } -list_all_versions() { +list_all_versions_sorted() { # TODO: Adapt this. By default we simply list the tag names from GitHub releases. # Change this function if tuist has other means of determining installable versions. - list_github_tags + list_github_tags_sorted } download_release() {