10

The Goal: Download github release tar.gz in Docker Build Script, so that the release files can be used for the docker image. I do not want the full source downloaded, which I can get to download through the archive path using the tag, but rather a build artifact that is part of the release.

To Be Noted: This is a download from a private repository, which is why I'm attempting to send my github_token as part of the command currently.

The Problem: I'm having trouble downloading a github release tar.gz using wget.

wget --header="Authorization: token <GITHUB_TOKEN>" --output-document=<FILENAME>.tar.gz https://github.com/<USER>/<REPO>/releases/download/<TAG>/<FILENAME>.tar.gz

This is returning the following error:

--2014-12-02 16:19:25--  https://github.com/<USER>/<REPO>/releases/download/<TAG>/<FILENAME>.tar.gz
Resolving github.com (github.com)... 192.30.252.131, 192.30.252.131
Connecting to github.com (github.com)|192.30.252.131|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2014-12-02 16:19:25 ERROR 404: Not Found.

It's worth noting that I'm not opposed to using curl for the download either or some other solution if necessary.

Joshua Pierce
  • 161
  • 1
  • 5
  • Does this answer your question? [How to download GitHub Release from private repo using command line](https://stackoverflow.com/questions/20396329/how-to-download-github-release-from-private-repo-using-command-line) – kenorb May 15 '20 at 23:28

2 Answers2

8

You can use the GitHub API.

To download a release using wget, you can do:

wget --header "Authorization: token <GITHUB TOKEN>"  --output-document=<RELEASE>.tar.gz https://api.github.com/repos/<USER>/<REPO>/tarball/<RELEASE NAME>

Use can change tarball to zipball to get a zip file.

Fedalto
  • 1,507
  • 1
  • 10
  • 13
  • Can this method be modified to get the latest release always, and the attached binaries therein, not tar or zip archives? – Rafs Jan 20 '23 at 13:29
0

The release.tar.gz part is set by the owner, so it is not generic.

$ wget https://github.com/XhmikosR/notepad2-mod/releases/download/4.2.25.935/Notepad2-mod.4.2.25.935.exe
--2014-12-02 11:16:42--  https://github.com/XhmikosR/notepad2-mod/releases/download/4.2.25.935/Notepad2-mod.4.2.25.935.exe
Resolving github.com (github.com)... 192.30.252.130
Connecting to github.com (github.com)|192.30.252.130|:443... connected.
HTTP request sent, awaiting response... 302 Found
Zombo
  • 1
  • 62
  • 391
  • 407
  • Sorry, I thought I had mentioned above that this is a private repository (My bad >.<), and I edited to show that the filename was redacted, the file name I'm sending in is the proper file name. – Joshua Pierce Dec 02 '14 at 17:49