diff --git a/deployments/cli/community/install.sh b/deployments/cli/community/install.sh index 582aa839413..6006fde66a2 100755 --- a/deployments/cli/community/install.sh +++ b/deployments/cli/community/install.sh @@ -57,13 +57,18 @@ function spinner() { function checkLatestRelease(){ echo "Checking for the latest release..." >&2 - local latest_release=$(curl -sSL https://api.github.com/repos/$GH_REPO/releases/latest | grep -o '"tag_name": "[^"]*"' | sed 's/"tag_name": "//;s/"//g') + if ! command -v python3 &> /dev/null; then + echo "python3 is required but not installed. Please install Python 3 and try again." >&2 + exit 1 + fi + local latest_release + latest_release=$(curl -fsSL "https://api.github.com/repos/$GH_REPO/releases/latest" | python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])" 2>/dev/null) if [ -z "$latest_release" ]; then echo "Failed to check for the latest release. Exiting..." >&2 exit 1 fi - echo $latest_release + echo "$latest_release" } function initialize(){ diff --git a/deployments/swarm/community/swarm.sh b/deployments/swarm/community/swarm.sh index d496c25e6de..abf17757c39 100755 --- a/deployments/swarm/community/swarm.sh +++ b/deployments/swarm/community/swarm.sh @@ -38,13 +38,18 @@ EOF function checkLatestRelease(){ echo "Checking for the latest release..." >&2 - local latest_release=$(curl -s https://api.github.com/repos/$GH_REPO/releases/latest | grep -o '"tag_name": "[^"]*"' | sed 's/"tag_name": "//;s/"//g') + if ! command -v python3 &> /dev/null; then + echo "python3 is required but not installed. Please install Python 3 and try again." >&2 + exit 1 + fi + local latest_release + latest_release=$(curl -fsSL "https://api.github.com/repos/$GH_REPO/releases/latest" | python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])" 2>/dev/null) if [ -z "$latest_release" ]; then echo "Failed to check for the latest release. Exiting..." >&2 exit 1 fi - echo $latest_release + echo "$latest_release" } # Function to read stack name from env file