How do I download binary files of a GitHub release?

Binary release assets exist outside of Git, and cannot be managed using the standard tools.

They should be available via GitHub's API, though.

  1. List the repository's release assets:

    GET /repos/:owner/:repo/releases/:id/assets
    

    This will send back a JSON document listing the release assets for the repository, e.g.

    [
      {
        "url": "https://api.github.com/repos/octocat/Hello-World/releases/assets/1",
        "browser_download_url": "https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip",
        "id": 1,
        "name": "example.zip",
        "label": "short description",
        "state": "uploaded",
        "content_type": "application/zip",
        "size": 1024,
        "download_count": 42,
        "created_at": "2013-02-27T19:35:32Z",
        "updated_at": "2013-02-27T19:35:32Z",
        "uploader": {
          "login": "octocat",
          ...
        }
      }
    ]
    
  2. Retrieve the assts from the release you want, as defined by its id from above:

    GET /repos/:owner/:repo/releases/assets/:id
    

    If you want to download the asset's binary content, pass a media type of "application/octet-stream". The API will either redirect the client to the location, or stream it directly if possible. API clients should handle both a 200 or 302 response.

As documented, these requests are all relative to https://api.github.com.


I've tried for days trying to find the proper answer to this, and finally I figured out how to do this via the curl command. It's a 3-step process.

First, to get a list of the assets for the latest release:

curl -H "Authorization: token YOURGITHUBTOKEN" \
    https://api.github.com/repos/NAME/REPO/releases/latest 

Then in the JSON, look up the url of the asset you want. For example it would look like:

"url": "https://api.github.com/repos/NAME/REPO/releases/assets/1275759"

Then you pass this to another curl command to retrieve the actual URL, which is actually a link to an Amazon S3 file.

curl -H "Authorization: token YOURGITHUBTOKEN" \
     -H "Accept:application/octet-stream" \
     -i https://api.github.com/repos/NAME/REPO/releases/assets/1275759

The URL will be in the "location" field of the HTTP response, and then use curl to get the file like this:

curl "https://github-cloud.s3.amazonaws.com...." -i -o FILENAME