Skip to content

Commit

Permalink
Merge pull request #6 from robzr/add_support_new_versions
Browse files Browse the repository at this point in the history
update to allow installing new versions
  • Loading branch information
adamcrews authored Mar 14, 2024
2 parents 2b854f8 + 3ae3807 commit aa09a1b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
18 changes: 10 additions & 8 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ 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.zip"
release_file_prefix="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION"

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

# Extract contents of zip file into the download directory
unzip -q "$release_file" -d "$ASDF_DOWNLOAD_PATH" || fail "Could not extract $release_file"
# Extract contents of archive file
if [ -f "${release_file_prefix}.zip" ]; then
unzip -q "${release_file_prefix}.zip" -d "$ASDF_DOWNLOAD_PATH" || fail "Could not extract ${release_file_prefix}.zip"
else
tar -xzf "${release_file_prefix}.tar.gz" -C "$ASDF_DOWNLOAD_PATH" || fail "Could not extract ${release_file_prefix}.tar.gz"
fi

# Remove the tar.gz file since we don't need to keep it
rm "$release_file"
# Remove the archive file since we don't need to keep it
rm -f "${release_file_prefix}.tar.gz" "${release_file_prefix}.zip"
19 changes: 13 additions & 6 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,25 @@ list_all_versions() {
}

download_release() {
local version filename url platform arch
local version filename found url_prefix platform arch
version="$1"
filename="$2"
filename="$2" # we will treat this like a prefix

platform=$(getPlatform)
arch=$(getArch)

# TODO: Adapt the release URL convention for tf-summarize
url="$GH_REPO/releases/download/v${version}/${TOOL_NAME}_${platform}_${arch}.zip"
url_prefix="$GH_REPO/releases/download/v${version}/${TOOL_NAME}_${platform}_${arch}"

echo "* Downloading $TOOL_NAME release $version..."
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
found=false
for extension in zip tar.gz; do

echo "* Downloading $TOOL_NAME release $version (trying $extension)..."
if curl "${curl_opts[@]}" -o "${filename}.${extension}" -C - "${url_prefix}.${extension}"; then
found=true
break
fi
done
$found || fail "Could not download $url_prefix(.tar.gz|.zip)"
}

install_version() {
Expand Down

0 comments on commit aa09a1b

Please sign in to comment.