From 71da719d6257a8d507741cf12547ce067fbbff69 Mon Sep 17 00:00:00 2001 From: Patrick Dawkins Date: Wed, 11 Mar 2026 15:13:05 +0000 Subject: [PATCH 1/4] fix: handle v-prefix in installer.sh for GoReleaser asset filenames GoReleaser strips the v prefix from asset filenames but keeps it in the tag/release path. The installer was using the tag name (with v) for both, causing 404s when downloading. Introduce a `tag` variable (always v-prefixed, for release URLs) and a `version` variable (without v, for asset filenames). Handles both `VERSION=5.10.0` and `VERSION=v5.10.0` from users. Closes CLI-112 Co-Authored-By: Claude Opus 4.6 (1M context) --- installer.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/installer.sh b/installer.sh index 56fdc470..c5c4a8d7 100644 --- a/installer.sh +++ b/installer.sh @@ -39,6 +39,7 @@ footer_notes="" has_sudo="" kernel="" machine="" +tag="" version="" package="upsun-cli" docs_url="https://docs.upsun.com" @@ -271,11 +272,24 @@ check_ca_certificates() { check_version() { if [ -z "${VERSION}" ]; then - version=$(curl -I https://github.com/upsun/cli/releases/latest 2>/dev/null | awk -F/ -v RS='\r\n' '/upsun.cli.releases.tag/ {printf "%s", $NF}') + tag=$(curl -I https://github.com/upsun/cli/releases/latest 2>/dev/null | awk -F/ -v RS='\r\n' '/upsun.cli.releases.tag/ {printf "%s", $NF}') + else + tag=${VERSION} + fi + + # Ensure the tag has the v prefix (for GitHub release URLs). + case "$tag" in + v*) ;; + *) tag="v${tag}" ;; + esac + + # The version without the v prefix (for asset filenames). + version=$(echo "$tag" | sed 's/^v//') + + if [ -z "${VERSION}" ]; then output " [*] No version specified, using latest ($version)" "success" else - output " [*] Version ${VERSION} specified" "success" - version=${VERSION} + output " [*] Version ${version} specified" "success" fi } @@ -608,7 +622,7 @@ install_raw() { # Start downloading the right version output "\nDownloading the $vendor_name CLI" "heading" - url="${URL}/${version}/${binary}_${version}_${kernel}_${machine}.tar.gz" + url="${URL}/${tag}/${binary}_${version}_${kernel}_${machine}.tar.gz" output " Downloading ${url}"; tmp_dir=$(mktemp -d) tmp_name="$binary-"$(date +"%s") From 2f0988abc8cdfcac66240431b83b728fcfe68319 Mon Sep 17 00:00:00 2001 From: Patrick Dawkins Date: Wed, 11 Mar 2026 15:28:18 +0000 Subject: [PATCH 2/4] fix: fail early if CLI version cannot be determined If /releases/latest returns nothing and no VERSION is specified, the installer would proceed with an empty version and fail later with a confusing error. Fail early with a clear message instead. Co-Authored-By: Claude Opus 4.6 (1M context) --- installer.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/installer.sh b/installer.sh index c5c4a8d7..55fe2b69 100644 --- a/installer.sh +++ b/installer.sh @@ -286,6 +286,11 @@ check_version() { # The version without the v prefix (for asset filenames). version=$(echo "$tag" | sed 's/^v//') + if [ -z "$version" ]; then + output " [ ] ERROR: Could not determine CLI version" "error" + exit_with_error + fi + if [ -z "${VERSION}" ]; then output " [*] No version specified, using latest ($version)" "success" else From eb174356ab82106db01272e3e1586c764a9cef04 Mon Sep 17 00:00:00 2001 From: Patrick Dawkins Date: Wed, 11 Mar 2026 15:35:12 +0000 Subject: [PATCH 3/4] fix: use parameter expansion instead of echo|sed for v-prefix strip Co-Authored-By: Claude Opus 4.6 (1M context) --- installer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer.sh b/installer.sh index 55fe2b69..94349a70 100644 --- a/installer.sh +++ b/installer.sh @@ -284,7 +284,7 @@ check_version() { esac # The version without the v prefix (for asset filenames). - version=$(echo "$tag" | sed 's/^v//') + version=${tag#v} if [ -z "$version" ]; then output " [ ] ERROR: Could not determine CLI version" "error" From a2fc2bf2a6a42c62400438071992768be7e32966 Mon Sep 17 00:00:00 2001 From: Patrick Dawkins Date: Wed, 11 Mar 2026 15:40:26 +0000 Subject: [PATCH 4/4] fix: use github_curl for version lookup to support GITHUB_TOKEN The version lookup now uses the GitHub API via github_curl, which supports GITHUB_TOKEN authentication. This avoids rate limiting on shared hosting where many users may run the installer. If no stable release exists (404), the tag will be empty and the existing version check will fail gracefully with a clear error. Co-Authored-By: Claude Opus 4.6 (1M context) --- installer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer.sh b/installer.sh index 94349a70..f7834ed4 100644 --- a/installer.sh +++ b/installer.sh @@ -272,7 +272,7 @@ check_ca_certificates() { check_version() { if [ -z "${VERSION}" ]; then - tag=$(curl -I https://github.com/upsun/cli/releases/latest 2>/dev/null | awk -F/ -v RS='\r\n' '/upsun.cli.releases.tag/ {printf "%s", $NF}') + tag=$(github_curl https://api.github.com/repos/upsun/cli/releases/latest 2>/dev/null | sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1) else tag=${VERSION} fi