The benefit of this solution is that you don't have to specify any release or tag number- it will just grab the LATEST.
TESTING:
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"
DIRECT:
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
INDIRECT:
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
Preferred Method:
However, please note as per Von's comment below that INDIRECT is the preferred method
Further Validation:
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:
DIRECT:
curl https://codeload.github.com/digitalocean/doctl/legacy.tar.gz/master | tar xzvf - --one-top-level="doctl" --strip-components 1
INDIRECT:
curl -L https://api.github.com/repos/digitalocean/doctl/tarball | tar xzvf - --one-top-level="doctl" --strip-components 1