Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnAmican committed Dec 7, 2023
1 parent 418ae9c commit d9dbef7
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,42 @@ list_all_versions() {
list_github_tags
}

get_machine_os() {
local OS
OS=$(uname -s | tr '[:upper:]' '[:lower:]')

case "${OS}" in
darwin*) echo "darwin" ;;
linux*) echo "linux" ;;
*) fail "OS not supported: ${OS}" ;;
esac
}

get_machine_arch() {
local ARCH
ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')

case "${ARCH}" in
i?86) echo "386" ;;
x86_64) echo "amd64" ;;
aarch64) echo "arm64" ;;
armv8l) echo "arm64" ;;
arm64) echo "arm64" ;;
*) fail "Architecture not supported: $ARCH" ;;
esac
}

download_release() {
local version filename url
version="$1"
filename="$2"

os=$(get_machine_os)
arch=$(get_machine_arch)

# TODO: Adapt the release URL convention for richgo
url="$GH_REPO/archive/v${version}.tar.gz"
# url="$GH_REPO/archive/v${version}.tar.gz"
url="${GH_REPO}/releases/download/v${version}/${TOOL_NAME}_${version}.tar.gz"

echo "* Downloading $TOOL_NAME release $version..."
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
Expand Down

0 comments on commit d9dbef7

Please sign in to comment.