From d5c5fd3b530a23b748775b0da78f6a56c996dadf Mon Sep 17 00:00:00 2001 From: kirillbilchenko Date: Mon, 12 Feb 2024 17:41:08 +0100 Subject: [PATCH 1/2] Add way to pass github token --- scripts/plugin_binloader.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/plugin_binloader.sh b/scripts/plugin_binloader.sh index ba26faa..d1d9762 100755 --- a/scripts/plugin_binloader.sh +++ b/scripts/plugin_binloader.sh @@ -103,10 +103,18 @@ getDownloadURLs() { echo "Retrieving $latest_url" if [ $DOWNLOADER = 'curl' ]; then - DOWNLOAD_URL=$(curl -sL "$latest_url" | grep "$OS-$ARCH" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) + if [ -z "${GITHUB_TOKEN}" ]; then + DOWNLOAD_URL=$(curl -sL "$latest_url" | grep "$OS-$ARCH" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) + else + DOWNLOAD_URL=$(curl -sL "$latest_url" --header "Authorization: Bearer ${GITHUB_TOKEN}" | grep "$OS-$ARCH" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) + fi PROJECT_CHECKSUM=$(curl -sL "$latest_url" | grep "$PROJECT_CHECKSUM_FILE" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) elif [ $DOWNLOADER = 'wget' ]; then - DOWNLOAD_URL=$(wget -q -O - "$latest_url" | grep "$OS-$ARCH" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) + if [ -z "${GITHUB_TOKEN}" ]; then + DOWNLOAD_URL=$(wget -q -O - "$latest_url" | grep "$OS-$ARCH" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) + else + DOWNLOAD_URL=$(wget -q --header="Authorization: Bearer ${GITHUB_TOKEN}" -O - "$latest_url" | grep "$OS-$ARCH" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) + fi PROJECT_CHECKSUM=$(wget -q -O - "$latest_url" | grep "$PROJECT_CHECKSUM_FILE" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) fi From f6867458859f61fb5135e945340e24f242b9cd96 Mon Sep 17 00:00:00 2001 From: kirillbilchenko Date: Mon, 12 Feb 2024 17:51:22 +0100 Subject: [PATCH 2/2] Add github token for checksum --- scripts/plugin_binloader.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/plugin_binloader.sh b/scripts/plugin_binloader.sh index d1d9762..3ee9a9c 100755 --- a/scripts/plugin_binloader.sh +++ b/scripts/plugin_binloader.sh @@ -105,17 +105,19 @@ getDownloadURLs() { if [ $DOWNLOADER = 'curl' ]; then if [ -z "${GITHUB_TOKEN}" ]; then DOWNLOAD_URL=$(curl -sL "$latest_url" | grep "$OS-$ARCH" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) + PROJECT_CHECKSUM=$(curl -sL "$latest_url" | grep "$PROJECT_CHECKSUM_FILE" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) else DOWNLOAD_URL=$(curl -sL "$latest_url" --header "Authorization: Bearer ${GITHUB_TOKEN}" | grep "$OS-$ARCH" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) + PROJECT_CHECKSUM=$(curl -sL "$latest_url" --header "Authorization: Bearer ${GITHUB_TOKEN}" | grep "$PROJECT_CHECKSUM_FILE" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) fi - PROJECT_CHECKSUM=$(curl -sL "$latest_url" | grep "$PROJECT_CHECKSUM_FILE" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) elif [ $DOWNLOADER = 'wget' ]; then if [ -z "${GITHUB_TOKEN}" ]; then DOWNLOAD_URL=$(wget -q -O - "$latest_url" | grep "$OS-$ARCH" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) + PROJECT_CHECKSUM=$(wget -q -O - "$latest_url" | grep "$PROJECT_CHECKSUM_FILE" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) else DOWNLOAD_URL=$(wget -q --header="Authorization: Bearer ${GITHUB_TOKEN}" -O - "$latest_url" | grep "$OS-$ARCH" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) + PROJECT_CHECKSUM=$(wget -q --header="Authorization: Bearer ${GITHUB_TOKEN}" -O - "$latest_url" | grep "$PROJECT_CHECKSUM_FILE" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) fi - PROJECT_CHECKSUM=$(wget -q -O - "$latest_url" | grep "$PROJECT_CHECKSUM_FILE" | awk '/"browser_download_url":/{gsub(/[,"]/,"", $2); print $2}' 2>/dev/null) fi if [ -z "$DOWNLOAD_URL" ]; then