From c9b5a536ca29044c3a844144d4b4191344ec6b5c Mon Sep 17 00:00:00 2001 From: Sarasa Kisaragi Date: Thu, 16 Apr 2020 15:01:36 +0800 Subject: [PATCH 1/2] Use local package if exist --- scripts/install_plugin.sh | 46 ++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/scripts/install_plugin.sh b/scripts/install_plugin.sh index e8befdf..8a3ad2a 100755 --- a/scripts/install_plugin.sh +++ b/scripts/install_plugin.sh @@ -8,29 +8,35 @@ if [ -n "${HELM_PUSH_PLUGIN_NO_INSTALL_HOOK}" ]; then fi version="$(cat plugin.yaml | grep "version" | cut -d '"' -f 2)" -echo "Downloading and installing helm-push v${version} ..." - -url="" -if [ "$(uname)" = "Darwin" ]; then - url="https://github.com/chartmuseum/helm-push/releases/download/v${version}/helm-push_${version}_darwin_amd64.tar.gz" -elif [ "$(uname)" = "Linux" ] ; then - url="https://github.com/chartmuseum/helm-push/releases/download/v${version}/helm-push_${version}_linux_amd64.tar.gz" +RELEASE_PACKAGE="releases/v${version}.tar.gz" +if [ ! -f ${RELEASE_PACKAGE} ]; then + echo "Downloading and installing helm-push v${version} ..." + + url="" + if [ "$(uname)" = "Darwin" ]; then + url="https://github.com/chartmuseum/helm-push/releases/download/v${version}/helm-push_${version}_darwin_amd64.tar.gz" + elif [ "$(uname)" = "Linux" ] ; then + url="https://github.com/chartmuseum/helm-push/releases/download/v${version}/helm-push_${version}_linux_amd64.tar.gz" + else + url="https://github.com/chartmuseum/helm-push/releases/download/v${version}/helm-push_${version}_windows_amd64.tar.gz" + fi + + echo $url + + mkdir -p "bin" + mkdir -p "releases/v${version}" + + # Download with curl if possible. + if [ -x "$(which curl 2>/dev/null)" ]; then + curl -sSL "${url}" -o ${RELEASE_PACKAGE} + else + wget -q "${url}" -O ${RELEASE_PACKAGE} + fi else - url="https://github.com/chartmuseum/helm-push/releases/download/v${version}/helm-push_${version}_windows_amd64.tar.gz" + echo "helm-push already exist..." fi -echo $url - -mkdir -p "bin" -mkdir -p "releases/v${version}" - -# Download with curl if possible. -if [ -x "$(which curl 2>/dev/null)" ]; then - curl -sSL "${url}" -o "releases/v${version}.tar.gz" -else - wget -q "${url}" -O "releases/v${version}.tar.gz" -fi -tar xzf "releases/v${version}.tar.gz" -C "releases/v${version}" +tar xzf ${RELEASE_PACKAGE} -C "releases/v${version}" mv "releases/v${version}/bin/helmpush" "bin/helmpush" || \ mv "releases/v${version}/bin/helmpush.exe" "bin/helmpush" From 1220a572e299e0bf0125af36fc36ad8dcde11824 Mon Sep 17 00:00:00 2001 From: Sarasa Kisaragi Date: Fri, 17 Apr 2020 10:04:57 +0800 Subject: [PATCH 2/2] Make sure `mkdir` ran --- scripts/install_plugin.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install_plugin.sh b/scripts/install_plugin.sh index 8a3ad2a..6b1cc99 100755 --- a/scripts/install_plugin.sh +++ b/scripts/install_plugin.sh @@ -23,9 +23,6 @@ if [ ! -f ${RELEASE_PACKAGE} ]; then echo $url - mkdir -p "bin" - mkdir -p "releases/v${version}" - # Download with curl if possible. if [ -x "$(which curl 2>/dev/null)" ]; then curl -sSL "${url}" -o ${RELEASE_PACKAGE} @@ -36,6 +33,9 @@ else echo "helm-push already exist..." fi +mkdir -p "bin" +mkdir -p "releases/v${version}" + tar xzf ${RELEASE_PACKAGE} -C "releases/v${version}" mv "releases/v${version}/bin/helmpush" "bin/helmpush" || \ mv "releases/v${version}/bin/helmpush.exe" "bin/helmpush"