Skip to content

Commit

Permalink
Fix: the install scripts now picks the latest version and binary from…
Browse files Browse the repository at this point in the history
… github (#1254)

- also fixed the kubectl-vela install script

Signed-off-by: Anoop Gopalakrishnan <[email protected]>
  • Loading branch information
anoop2811 committed Jul 14, 2023
1 parent 49e8a50 commit d08c4c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion static/script/install-kubectl-vela.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
KUBECTL_VELA_HTTP_REQUEST_CLI=curl

# GitHub Organization and repo name to download release
GITHUB_ORG=oam-dev
GITHUB_ORG=kubevela
GITHUB_REPO=kubevela

# Kubectl-Vela CLI filename
Expand Down
22 changes: 18 additions & 4 deletions static/script/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ VELA_CLI_FILENAME=vela

VELA_CLI_FILE="${VELA_INSTALL_DIR}/${VELA_CLI_FILENAME}"

DOWNLOAD_BASE="https://static.kubevela.net/binary/vela"
VERSION_CHECK_BASE="https://api.github.com/repos/kubevela/kubevela"
DOWNLOAD_BASE="https://github.com/kubevela/kubevela/releases/download"

getSystemInfo() {
ARCH=$(uname -m)
Expand Down Expand Up @@ -83,13 +84,26 @@ checkExistingVela() {
}

getLatestRelease() {
local velaReleaseUrl="${DOWNLOAD_BASE}/latest_version"
local velaReleaseUrl="${VERSION_CHECK_BASE}/releases/latest"
local latest_release=""
local response=""

if [ "$VELA_HTTP_REQUEST_CLI" == "curl" ]; then
latest_release=$(curl -s $velaReleaseUrl)
response=$(curl -s $velaReleaseUrl)
else
latest_release=$(wget -q -O - $velaReleaseUrl)
response=$(wget -q -O - $velaReleaseUrl)
fi

if [[ "$response" == *"Not Found"* ]]; then
echo "Error: Repository or release not found."
return 1
fi

latest_release=$(echo "$response" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

if [ -z "$latest_release" ]; then
echo "Error: Unable to retrieve the latest version."
return 1
fi

ret_val=$latest_release
Expand Down

0 comments on commit d08c4c3

Please sign in to comment.