Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ footer_notes=""
has_sudo=""
kernel=""
machine=""
tag=""
version=""
package="upsun-cli"
docs_url="https://docs.upsun.com"
Expand Down Expand Up @@ -271,11 +272,29 @@ 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=$(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

# 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=${tag#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
output " [*] Version ${VERSION} specified" "success"
version=${VERSION}
output " [*] Version ${version} specified" "success"
fi
}

Expand Down Expand Up @@ -608,7 +627,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")
Expand Down
Loading