From 73c3aa5bd09bed5c3d3bf1cf3640917c0ec9220d Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Thu, 25 Apr 2024 10:58:11 -0400 Subject: [PATCH] coder: fix update script to use highest stable version (#306284) * coder: use highest stable version not latest version This would previously fetch 2.9.4 instead of 2.10.3 if 2.9.4 was released afterwards. Coder frequently releases patches for older versions, so we must sort by version. This same pattern is done in their install script. * Update pkgs/development/tools/coder/update.sh Co-authored-by: superherointj <5861043+superherointj@users.noreply.github.com> --------- Co-authored-by: superherointj <5861043+superherointj@users.noreply.github.com> --- pkgs/development/tools/coder/update.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/development/tools/coder/update.sh b/pkgs/development/tools/coder/update.sh index ebd40e3d5adb..335c20dd55a4 100755 --- a/pkgs/development/tools/coder/update.sh +++ b/pkgs/development/tools/coder/update.sh @@ -5,9 +5,7 @@ set -eu -o pipefail cd "$(dirname "${BASH_SOURCE[0]}")" -# Fetch the latest stable version -LATEST_STABLE_TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --silent https://api.github.com/repos/coder/coder/releases/latest | jq -r '.tag_name') -LATEST_STABLE_VERSION=$(echo ${LATEST_STABLE_TAG} | sed 's/^v//') +LATEST_STABLE_VERSION=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --fail -sSL https://api.github.com/repos/coder/coder/releases | jq -r 'map(select(.prerelease == false)) | sort_by(.tag_name | sub("^v"; "") | split(".") | map(tonumber)) | .[-1].tag_name | sub("^v"; "")') # Fetch the latest mainline version LATEST_MAINLINE_TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --silent https://api.github.com/repos/coder/coder/releases | jq -r '.[0].tag_name')