Last active
October 13, 2023 13:44
-
-
Save suuhm/fe9867e7dfa1c273a77129dd5c4c2794 to your computer and use it in GitHub Desktop.
Script for Downloading/ Listing all (or one) files from the latest github realeases of a specific repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# github_repo_release_downloader.sh (c) suuhm - 2023 | |
# -------------------------------------------------- | |
# Download/list all wished files in a Github repository: | |
# | |
# | |
# Options: | |
# ./github_repo_release_downloader.sh | |
# --list : List all files in Repo | |
# --all : All files download | |
# --filename "FILENAME_PATTERN" : Download only this filename pattern | |
# Setup your wished Repository in form <USER/REPOSITORY>: | |
_R="username/Repository" | |
read -p "Enter your Repository (username/REPONAME): " _R | |
_RD=$(echo $_R | sed 's/.*\///') | |
mkdir -p $_RD ; cd $_RD | |
if [ "$1" == "--list" ]; then | |
echo -e "\n[*] List all files in Repository: ${_R}\n" ; sleep 1 | |
# Filter with filename-extension | |
# | egrep '"name.*\.[a-z]{2,3}' | |
curl -s https://api.github.com/repos/${_R}/releases/latest | grep "\"name\":.*" | sed 's/.*"\([^"]*\)".*/\-\>\ \1/g' | |
echo; exit 0; | |
fi | |
if [ "$1" == "--all" ]; then | |
echo -e "\n[*] Download all files in Repository: ${_R}\n" ; sleep 1 | |
curl -s https://api.github.com/repos/${_R}/releases/latest | grep "browser_download_url.*" | sed 's/.*"\(https:\/\/[^"]*\)".*/\1/g' | wget --show-progress -qi - | |
elif [ "$1" == "--filename" ]; then | |
echo -e "\n[*] Download file(s) with pattern: "$2" in Repository: ${_R}\n" ; sleep 1 | |
curl -s https://api.github.com/repos/${_R}/releases/latest | grep -i "browser_download_url.*$2.*" | sed 's/.*"\(https:\/\/[^"]*\)".*/\1/g' | wget --show-progress -qi - | |
else | |
results=1 | |
echo -e "\n[*] Download for your arch: $(uname -m) in Repository: ${_R}\n" ; sleep 1 | |
curl -s https://api.github.com/repos/${_R}/releases/latest | grep "browser_download_url.*$(uname -m).*" | sed 's/.*"\(https:\/\/[^"]*\)".*/\1/g' | head -n${results} | wget --show-progress -qi - | |
fi | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment