We needed to download a software from Github in its latest release without specifying the version number. This had to be done with curl, so we came up with the following code.


First we have to retrieve all the data about the latest release, which can be easily done by the use of the GitHub API. The URL follows the same scheme:

In our case:

The result is a JSON file with the description of the release and download links for specific files:

  "url": "",
  "id": 11040706,
  "node_id": "MDEyOlJlbGVhc2VBc3NldDExMDQwNzA2",
  "name": "swamp_amd64",
  "label": null,
  "uploader": {
    "login": "felixb",
    "id": 192135,
    "node_id": "MDQ6VXNlcjE5MjEzNQ==",
    "avatar_url": "",
    "gravatar_id": "",
    "url": "",
    "html_url": "",
    "followers_url": "",
    "following_url": "{/other_user}",
    "gists_url": "{/gist_id}",
    "starred_url": "{/owner}{/repo}",
    "subscriptions_url": "",
    "organizations_url": "",
    "repos_url": "",
    "events_url": "{/privacy}",
    "received_events_url": "",
    "type": "User",
    "site_admin": false
  "content_type": "application/octet-stream",
  "state": "uploaded",
  "size": 11765256,
  "download_count": 916,
  "created_at": "2019-02-12T06:39:41Z",
  "updated_at": "2019-02-12T06:39:49Z",
  "browser_download_url": ""

Now we can write our curl command to retrieve the download URL for the Linux version.

DOWNLOAD_URL=$(curl -s \
        | grep browser_download_url \
        | grep swamp_amd64 \
        | cut -d '"' -f 4)
curl -s -L --create-dirs -o ~/downloadDir "$DOWNLOAD_URL"

Note: Replace the repository URL and grep swamp_amd64 with the file you need (grep YOUR_FILE).