Files
various-scripts/releases_downloader_github

47 lines
1.1 KiB
Plaintext

GITHUB_USER=""
GITHUB_SECRET=""
REPO_OWNER="ich777"
REPO_NAME="unraid-nvidia-driver"
BASE_PATH=~/Repo
#Get all release numbers:
RELEASES="$(curl -u $GITHUB_USER:$GITHUB_SECRET -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/tags | jq -r '.[].name')"
if [ -z "${RELEASES}" ]; then
echo "Something went wrong, can't get Releases"
exit 1
fi
#Create folders for releases:
if [ ! -d ${BASE_PATH} ]; then
mkdir -p ${BASE_PATH}
fi
while read -r line
do
mkdir -p ${BASE_PATH}/$line
done <<< "${RELEASES}"
#Download releases:
while read -r line
do
cd ${BASE_PATH}/$line
DL_URLS="$(curl -u $GITHUB_USER:$GITHUB_SECRET -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/tags/$line | jq -r '.assets[].browser_download_url')"
echo "Staring download(s) for Release: $line"
if [ -z "${DL_URLS}" ]; then
echo "Something went wrong, can't get download URLs"
exit 1
fi
while read -r line
do
wget -q -nc --show-progress $line
done <<< "${DL_URLS}"
done <<< "${RELEASES}"
cd ${BASE_PATH}