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>
This commit is contained in:
Kyle Carberry 2024-04-25 10:58:11 -04:00 committed by GitHub
parent 14fefb3ffd
commit 73c3aa5bd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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')