about summary refs log tree commit diff
path: root/pkgs/development/tools/coder/update.sh
diff options
context:
space:
mode:
authorKyle Carberry <kyle@carberry.com>2024-04-29 20:57:00 -0400
committerKyle Carberry <kyle@carberry.com>2024-04-29 20:57:31 -0400
commite866acb9d9ad4979377a704ae6b2a18569c1ec17 (patch)
treee5e9896baaa4a0605ee96ede204a20e62fd1b970 /pkgs/development/tools/coder/update.sh
parentce987aa9a0cd723770a8a86328cb04cdf744e8e3 (diff)
coder: fix update.sh for stable release
Previously, this used the incorrect method of fetching
the stable release, so mainline was always used.
Diffstat (limited to 'pkgs/development/tools/coder/update.sh')
-rwxr-xr-xpkgs/development/tools/coder/update.sh9
1 files changed, 4 insertions, 5 deletions
diff --git a/pkgs/development/tools/coder/update.sh b/pkgs/development/tools/coder/update.sh
index 335c20dd55a4a..60e9a97af2217 100755
--- a/pkgs/development/tools/coder/update.sh
+++ b/pkgs/development/tools/coder/update.sh
@@ -5,11 +5,10 @@ set -eu -o pipefail
 
 cd "$(dirname "${BASH_SOURCE[0]}")"
 
-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')
-LATEST_MAINLINE_VERSION=$(echo ${LATEST_MAINLINE_TAG} | sed 's/^v//')
+# The released tagged as "latest" is always stable.
+LATEST_STABLE_VERSION=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --fail -sSL https://api.github.com/repos/coder/coder/releases/latest | jq -r '.tag_name | sub("^v"; "")')
+# The highest version that is not a pre-release is the latest mainline version.
+LATEST_MAINLINE_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"; "")')
 
 # Define the platforms
 declare -A ARCHS=(["x86_64-linux"]="linux_amd64.tar.gz"