asdf-kubevela/bin/download

49 lines
981 B
Plaintext
Raw Normal View History

2022-09-13 16:28:48 +08:00
#!/usr/bin/env bash
set -euo pipefail
current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "$current_script_path")")
# shellcheck source=../lib/utils.bash
source "${plugin_dir}/lib/utils.bash"
mkdir -p "$ASDF_DOWNLOAD_PATH"
case $(uname -m) in
x86_64)
ARCH=amd64
;;
arm64|aarch64)
ARCH=arm64
;;
*)
exit -1
;;
esac
OS="$(uname -s | tr '[[:upper:]]' '[[:lower:]]')"
case $OS in
linux|darwin)
;;
*)
exit -1
;;
esac
FILES=(
"kubectl-vela-v$ASDF_INSTALL_VERSION-$OS-$ARCH.tar.gz"
"vela-v$ASDF_INSTALL_VERSION-$OS-$ARCH.tar.gz"
)
for FILE in "${FILES[@]}"; do
# Download tar.gz file to the download directory
download_release "$ASDF_INSTALL_VERSION" "$FILE"
# Extract contents of tar.gz file into the download directory
tar -xzf "$FILE" -C "$ASDF_DOWNLOAD_PATH" --strip-components=1 || fail "Could not extract $FILE"
# Remove the tar.gz file since we don't need to keep it
rm "$FILE"
done