Skip to content

Commit

Permalink
Download release binaries, not repo
Browse files Browse the repository at this point in the history
  • Loading branch information
xx4h committed Oct 1, 2024
1 parent 3a6cdcf commit 4f200b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
3 changes: 1 addition & 2 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ source "${plugin_dir}/lib/utils.bash"

mkdir -p "$ASDF_DOWNLOAD_PATH"

# TODO: Adapt this to proper extension and adapt extracting strategy.
release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.tar.gz"

# Download tar.gz file to the download directory
download_release "$ASDF_INSTALL_VERSION" "$release_file"

# Extract contents of tar.gz file into the download directory
tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" --strip-components=1 || fail "Could not extract $release_file"
tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" || fail "Could not extract $release_file"

# Remove the tar.gz file since we don't need to keep it
rm "$release_file"
16 changes: 11 additions & 5 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,24 @@ list_github_tags() {
}

list_all_versions() {
# TODO: Adapt this. By default we simply list the tag names from GitHub releases.
# Change this function if hctl has other means of determining installable versions.
list_github_tags
}

get_os() {
uname | tr '[:upper:]' '[:lower:]'
}

get_arch() {
uname -m
}

download_release() {
local version filename url
local version filename release_name url
version="$1"
filename="$2"
release_name="${TOOL_NAME}_$(get_os)_$(get_arch)"

# TODO: Adapt the release URL convention for hctl
url="$GH_REPO/archive/v${version}.tar.gz"
url="$GH_REPO/releases/download/v${version}/${release_name}.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 4f200b0

Please sign in to comment.