You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB
Plaintext

#!/usr/bin/env bash
6 months ago
set -euo pipefail
# shellcheck disable=SC1090
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
APP=helm
6 months ago
VERSION=${VERSION:-3.15.2}
DEST=${XDG_DATA_HOME}/apps/releases/${APP}
if [[ ! -d "${DEST}/${VERSION}" ]]; then
DL_DIR="$(mktemp -d)"
SHA_PATH=${DL_DIR}/helm.tar.gz.sha256
TAR_PATH=${DL_DIR}/helm.tar.gz
URL_SHA=https://get.helm.sh/helm-v${VERSION}-$(get_os)-$(get_arch).tar.gz.sha256
URL_TAR=https://get.helm.sh/helm-v${VERSION}-$(get_os)-$(get_arch).tar.gz
curl --silent --location --output "${SHA_PATH}" "${URL_SHA}"
curl --silent --location --output "${TAR_PATH}" "${URL_TAR}"
if [[ $(cat "${SHA_PATH}") != $(openssl dgst -sha256 "${TAR_PATH}" | sed -e 's/^.* //') ]]; then
echo 'checksum does not match'
rm -rf "${DL_DIR}"
exit 1
fi
mkdir_if_missing "${DEST}/${VERSION}"
tar xzf "${TAR_PATH}" --directory "${DEST}/${VERSION}" --strip-component 1
rm -rf "${DL_DIR}"
fi
set_current_link "${DEST}" "${VERSION}"
unlink_if_set "$XDG_BIN_HOME/${APP}"
cd "$XDG_BIN_HOME" || exit 1
ln -s "$(relative_path "${XDG_BIN_HOME}" "${DEST}/current/${APP}")" ${APP}
cd - >/dev/null || exit 1