diff --git a/scripts/get b/scripts/get index bc13039e2..4daf504da 100755 --- a/scripts/get +++ b/scripts/get @@ -78,16 +78,31 @@ verifySupported() { # checkDesiredVersion checks if the desired version is available. checkDesiredVersion() { # Use the GitHub releases webpage for the project to find the desired version for this project. - local release_url="https://github.com/helm/helm/releases/${DESIRED_VERSION:-latest}" + local latest_release_url="https://github.com/helm/helm/releases/latest" + local release_url + if [ "x$DESIRED_VERSION" == "x" ]; then + if type "curl" > /dev/null; then + release_url=$(curl -Ls -o /dev/null -w %{url_effective} $latest_release_url) + elif type "wget" > /dev/null; then + release_url=$(wget $latest_release_url --server-response -O /dev/null 2>&1 | awk '/^ Location: /{DEST=$2} END{ print DEST}') + fi + else + release_url="https://github.com/helm/helm/releases/${DESIRED_VERSION}" + fi + + local status_code if type "curl" > /dev/null; then - TAG=$(curl -SsL $release_url | awk '/\/tag\//' | grep -v no-underline | grep " /dev/null; then - TAG=$(wget -q -O - $release_url | awk '/\/tag\//' | grep -v no-underline | grep "&1 | grep "HTTP/" | awk '{print $2}') fi - if [ "x$TAG" == "x" ]; then + + if [[ "$status_code" -ne 200 ]] ; then echo "Cannot determine ${DESIRED_VERSION} tag." exit 1 fi + + TAG=$(echo $release_url | grep -oE "[^/]+$" ) } # checkHelmInstalledVersion checks which version of helm is installed and