Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sasqwatch/d0fdef0c2710a317e54acffd1fe1ee7e to your computer and use it in GitHub Desktop.
Save sasqwatch/d0fdef0c2710a317e54acffd1fe1ee7e to your computer and use it in GitHub Desktop.
One Liner to Download the Latest Release from Github Repo
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi -

curl -s https://api.github.com/repos/jgm/pandoc/releases/latest
| grep "browser_download_url.*deb"
| cut -d '"' -f 4
| wget -qi -

Wildcard didn't work on Docker ubuntu:latest But this did. just broke out the greps. curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest
| grep browser_download_url
| grep linux64
| cut -d '"' -f 4
| wget -qi -

Shorter PCRE grep: (just get's the version number) curl -s https://api.github.com/repos/USER/REPO/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")' curl -sL https://api.github.com/repos/USER/REPO/releases/latest | jq -r '.assets[].browser_download_url'

curl -s https://api.github.com/repos/USER/REPO/releases/latest | jq -r ".assets[] | select(.name | contains("search param for specific download url")) | .browser_download_url" | wget -i -

curl --silent "https://api.github.com/repos/USER/REPO/releases/latest" | # Get latest release from GitHub api grep '"tag_name":' | # Get tag line sed -E 's/."([^"]+)"./\1/' | xargs -I {} curl -sOL "https://github.com/USER/REPO/archive/"{}'.tar.gz'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment