Skip to content

Commit

Permalink
Fix download-binary
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Nov 9, 2023
1 parent d847c97 commit 2f5b26e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions scripts/download-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ download_release_asset() {
echo "Downloading ${latest_release} release..."
curl -s -L -o "${ASSET}" "$download_url"
curl -s -L -o checksums.txt "https://github.com/${repo_owner}/${repo_name}/releases/download/${latest_release}/checksums.txt"
CHECKSUM_SOURCE=$(grep "$ASSET" checksums.txt)
CHECKSUM_DL=$(sha256sum $ASSET)
CHECKSUM_SOURCE=$(grep "${ASSET}" checksums.txt)
CHECKSUM_DL=$(sha256sum "${ASSET}")
if [ "$CHECKSUM_SOURCE" != "$CHECKSUM_DL" ]; then
echo "Checksums do not match."
rm "$ASSET" checksums.txt
rm "${ASSET}" checksums.txt
exit 1
fi

if [[ "$GOOS" == "Windows" ]]; then
unzip $ASSET
unzip "${ASSET}"
else
tar -zxf "$ASSET"
tar -zxf "${ASSET}"
fi
rm $ASSET checksums.txt
rm "${ASSET}" checksums.txt
}

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
Expand All @@ -54,7 +54,6 @@ fi

# Fetch the latest release version using GitHub API
latest_release=$(curl -s "https://api.github.com/repos/${repo_owner}/${repo_name}/releases/latest" | jq -r '.tag_name')
latest_version=$(echo "${latest_release}" | cut -c 2-)

# Check if the latest release version is available
if [ -z "$latest_release" ]; then
Expand All @@ -71,7 +70,7 @@ fi

# Check if the required binary for the user's architecture exists in the latest release
binary_filename="${binary_name}_${GOOS}_${GOARCH}${binary_extension}"
echo "Binary filename: " $binary_filename
echo "Binary filename: ${binary_filename}"
release_assets=$(curl -s "https://api.github.com/repos/${repo_owner}/${repo_name}/releases/tags/${latest_release}" | jq -r '.assets[].name')
if [[ "$release_assets" == *"$binary_filename"* ]]; then
echo "Binary for ${GOOS}-${GOARCH} architecture found in the latest release."
Expand Down

0 comments on commit 2f5b26e

Please sign in to comment.