How to download all files from GitHub release?
Asked Answered
C

3

5

I am looking at a GitHub release that contains over 200 .tgz files that I want to download. Is there any way to download them all in bulk within one line/script, as opposed to downloading them each individually?

Because it is not exactly hosted on the GitHub repository, I can't clone the master repository either. How should I go about this efficiently?

Cockiness answered 4/4, 2021 at 22:38 Comment(0)
E
8

The github cli (gh) can be used for this. Here are the docs.

This is for downloading all files (github release assets) from a specific github release.

gh release list -R <username>/<repo>
gh release download <tag> -D <dest> -R <username>/<repo>

# for eg.
gh release list -R cli/cli
gh release download v2.21.2 -D gh_v2.21.2 -R cli/cli

# download all assets from latest release to gh_latest directory
gh release download -p "*" -D gh_latest -R cli/cli

Note:

  • If you are in a git repository, gh release download <tag> will download all the assets from the latest release to the current directory. No need to specify -R -D.

  • If the tag is not specified, it will download the latest release but complain that one of the -A or -p flags is required. In such case gh release download -p "*" can be used.

  • Check the examples in the docs for more.

Euphemia answered 9/1, 2023 at 23:43 Comment(1)
Here's a way to download the latest release gh release download -R raaka/cpp `gh release list -R raaka/cpp -L 1| awk '{print $5}'` until github.com/cli/cli/issues/2310 is fixed.Shuddering
S
3

You can use the GitHub API to get a list of releases and to download each release by tag name.

Reference:

Stroman answered 4/4, 2021 at 22:43 Comment(0)
S
0

A shell (Bash) script for Linux/Mac to download all release assets from latest release:

replace <USER> and <REPO_NAME> with names you need.

REPO_URL='https://api.github.com/repos/<USER>/<REPO_NAME>/releases/latest'

RESPONSE_LIST=$(curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" $REPO_URL)

for f in $(echo "$RESPONSE_LIST" | grep browser_download | cut -d\" -f4); do wget "$f"; done;

add -H "Authorization: Bearer <YOUR_API_KEY>" header to curl command to also download from a private repo.

Sidewheel answered 20/9, 2024 at 19:41 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.