@@ -24,13 +24,20 @@ if [[ "$1" == "-y" ]] || [[ "$CI" == "1" ]] || [[ "$CI" == "true" ]]; then
24
24
CI="1"
25
25
fi
26
26
27
- # Use curl to fetch the latest release data
28
- echo "Fetching the latest release information..."
29
- RELEASE_JSON=$(curl -s -L https://api.github.com/repos/DefangLabs/defang/releases/latest)
27
+ # check if DEFANG_INSTALL_VERSION is set and set the release path accordingly
28
+ if [[ -z "$DEFANG_INSTALL_VERSION" ]]; then
29
+ RELEASE_PATH="latest"
30
+ else
31
+ RELEASE_PATH="tags/$DEFANG_INSTALL_VERSION"
32
+ fi
33
+
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)
30
37
31
38
# Check for curl failure
32
- if [ $? -ne 0 ]; then
33
- 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."
34
41
return 1
35
42
fi
36
43
@@ -73,7 +80,7 @@ elif [ "$OS" = "Linux" ]; then
73
80
fi
74
81
75
82
# Download the file
76
- if ! curl -s -L "$DOWNLOAD_URL" -o "$FILENAME"; then
83
+ if ! curl -s -f - L "$DOWNLOAD_URL" -o "$FILENAME"; then
77
84
echo "Download failed. Please check your internet connection and try again."
78
85
return 4
79
86
fi
@@ -232,5 +239,5 @@ rm "$FILENAME"
232
239
echo "Installation completed. You can now use defang by typing '$BINARY_NAME' in the terminal."
233
240
234
241
# Unset the variables and functions to avoid polluting the user's environment
235
- unset EXTRACT_DIR DOWNLOAD_URL RELEASE_JSON ARCH_SUFFIX ARCH OS FILENAME INSTALL_DIR BINARY_NAME REPLY EXPORT_PATH CURRENT_SHELL FOUND_PROFILE_FILE
242
+ unset EXTRACT_DIR DOWNLOAD_URL RELEASE_JSON RELEASE_PATH ARCH_SUFFIX ARCH OS FILENAME INSTALL_DIR BINARY_NAME REPLY EXPORT_PATH CURRENT_SHELL FOUND_PROFILE_FILE
236
243
unset -f _prompt_and_append_to_file _generate_completion_script _install_completion_script
0 commit comments