Using GitHub\'s Release feature, it is possible to provide a link to download a specific version of the published software. However, every time a release is made, the gh-pag
Like most visiting this question, I was absolutely frustrated with finding a way to fully automate download of the LATEST versioned release or a repo in Github. The benefit of this solution is that you do not have to specify any release or tag number- it will just grab the LATEST.
I conducted my testing using the following Github user & repo:
"f1linux" = Github User
"pi-ap" = Repo
The arbitrary directory name the repo is saved to is set in:
--one-top-level="pi-ap"
Using Firefox's "Web Developer" tools (3 bars in upper right corner), in the "Network" section I found https://api.github.com
was redirecting to https://codeload.github.com
, so by piping the curl
to tar
I was able to grab the latest versioned repo and save it to a predictable name so it could be operated on:
curl https://codeload.github.com/f1linux/pi-ap/legacy.tar.gz/master | tar xzvf - --one-top-level="pi-ap" --strip-components 1
After I achieved fully-automated downloads of the latest versioned release using a DIRECT URL, I turned my attention to achieving the same with Github's redirection:
curl -L https://api.github.com/repos/f1linux/pi-ap/tarball | tar xzvf - --one-top-level="pi-ap" --strip-components 1
However, please note as per Von's comment below that INDIRECT is the preferred method
To ensure my results were reproducible to other versioned Github repos, the same tests were successfully executed for Digital Ocean's doctl
api toolkit (which is what started the whole exercise actually!):
Both DIRECT and INDIRECT work using the same form as above, just changing the username & repo:
curl https://codeload.github.com/digitalocean/doctl/legacy.tar.gz/master | tar xzvf - --one-top-level="doctl" --strip-components 1
curl -L https://api.github.com/repos/digitalocean/doctl/tarball | tar xzvf - --one-top-level="doctl" --strip-components 1