Skip to content

Commit d9dbef7

Browse files
committed
1 parent 418ae9c commit d9dbef7

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

lib/utils.bash

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,42 @@ list_all_versions() {
3636
list_github_tags
3737
}
3838

39+
get_machine_os() {
40+
local OS
41+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
42+
43+
case "${OS}" in
44+
darwin*) echo "darwin" ;;
45+
linux*) echo "linux" ;;
46+
*) fail "OS not supported: ${OS}" ;;
47+
esac
48+
}
49+
50+
get_machine_arch() {
51+
local ARCH
52+
ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
53+
54+
case "${ARCH}" in
55+
i?86) echo "386" ;;
56+
x86_64) echo "amd64" ;;
57+
aarch64) echo "arm64" ;;
58+
armv8l) echo "arm64" ;;
59+
arm64) echo "arm64" ;;
60+
*) fail "Architecture not supported: $ARCH" ;;
61+
esac
62+
}
63+
3964
download_release() {
4065
local version filename url
4166
version="$1"
4267
filename="$2"
4368

69+
os=$(get_machine_os)
70+
arch=$(get_machine_arch)
71+
4472
# TODO: Adapt the release URL convention for richgo
45-
url="$GH_REPO/archive/v${version}.tar.gz"
73+
# url="$GH_REPO/archive/v${version}.tar.gz"
74+
url="${GH_REPO}/releases/download/v${version}/${TOOL_NAME}_${version}.tar.gz"
4675

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

0 commit comments

Comments
 (0)