Skip to content

Commit 4daa198

Browse files
committed
reformat and add error message for bad version
1 parent 96b3c9e commit 4daa198

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/bin/install

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ fi
2626

2727
# check if DEFANG_INSTALL_VERSION is set and set the release path accordingly
2828
if [[ -z "$DEFANG_INSTALL_VERSION" ]]; then
29-
RELEASE_PATH="/latest"
29+
RELEASE_PATH="latest"
3030
else
31-
RELEASE_PATH="/tags/$DEFANG_INSTALL_VERSION"
31+
RELEASE_PATH="tags/$DEFANG_INSTALL_VERSION"
3232
fi
3333

34-
# Use curl to fetch the latest release data
35-
echo "Fetching the latest release information..."
36-
RELEASE_JSON=$(curl -s -L https://api.github.com/repos/DefangLabs/defang/releases$RELEASE_PATH)
34+
# Echo fetching the release path either latest or strip the tags/ from the version
35+
echo "Fetching the ${DEFANG_INSTALL_VERSION:-latest} release of defang..."
36+
RELEASE_JSON=$(curl -s -f -L https://api.github.com/repos/DefangLabs/defang/releases/$RELEASE_PATH)
3737

3838
# Check for curl failure
39-
if [ $? -ne 0 ]; then
40-
echo "Error fetching release information. Please check your connection or if the URL is correct."
39+
if [ -z "$RELEASE_JSON" ]; then
40+
echo "Error fetching release information. Please check your connection or if the version is correct."
4141
return 1
4242
fi
4343

@@ -80,7 +80,7 @@ elif [ "$OS" = "Linux" ]; then
8080
fi
8181

8282
# Download the file
83-
if ! curl -s -L "$DOWNLOAD_URL" -o "$FILENAME"; then
83+
if ! curl -s -f -L "$DOWNLOAD_URL" -o "$FILENAME"; then
8484
echo "Download failed. Please check your internet connection and try again."
8585
return 4
8686
fi

0 commit comments

Comments
 (0)