From 2b70cbb1f4bb2340e6e795d9e77802bf9adced91 Mon Sep 17 00:00:00 2001 From: Douwe Osinga Date: Tue, 17 Feb 2026 14:39:03 +0100 Subject: [PATCH] Fix copied over --- download_cli.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/download_cli.sh b/download_cli.sh index 288f072526b3..152c756e43ec 100755 --- a/download_cli.sh +++ b/download_cli.sh @@ -197,8 +197,27 @@ DOWNLOAD_URL="https://github.com/$REPO/releases/download/$RELEASE_TAG/$FILE" # --- 4) Download & extract 'goose' binary --- echo "Downloading $RELEASE_TAG release: $FILE..." if ! curl -sLf "$DOWNLOAD_URL" --output "$FILE"; then - echo "Error: Failed to download $DOWNLOAD_URL" - exit 1 + # If the download fails, only fall back to latest stable when no version was specified and canary was not requested). + if ! [ -n "${GOOSE_VERSION:-}" ] && [ "${CANARY:-false}" != "true" ]; then + LATEST_TAG=$(curl -s https://api.github.com/repos/block/goose/releases/latest | \ + grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + if [ -z "$LATEST_TAG" ]; then + echo "Error: Failed to download $DOWNLOAD_URL and latest tag unavailable" + exit 1 + fi + + DOWNLOAD_URL="https://github.com/$REPO/releases/download/$LATEST_TAG/$FILE" + if curl -sLf "$DOWNLOAD_URL" --output "$FILE"; then + # Fallback succeeded + : + else + echo "Error: Failed to download from fallback url $DOWNLOAD_URL using latest tag $LATEST_TAG" + exit 1 + fi + else + echo "Error: Failed to download $DOWNLOAD_URL" + exit 1 + fi fi # Create a temporary directory for extraction