Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub URL for latest release of the _download file_?

Tags:

github

Although this question is similar to GitHub latest release, it's actually different -- it's about a link that means "the latest version of the download file itself".

GitHub provides a "Latest" URL that redirects to the information page for the latest release. For example: https://github.com/reactiveui/ReactiveUI/releases/latest will redirect to https://github.com/reactiveui/ReactiveUI/releases/tag/5.99.6 (as I type this; or to the page for a newer version, someday).

That's great but I need a URL to the download file itself. In this example, the .zip file associated with the green download button, https://github.com/reactiveui/ReactiveUI/releases/download/5.99.6/ReactiveUI-5.99.6.zip (as I type this; or to a newer zip file, someday).

Why? I want to give the URL to curl, as part of a Travis CI script, to download the latest version.

I guessed at a few URLs like /releases/download/latest/file.zip (substituting "latest" for the version part) and /releases/download/file.zip but those 404.

Is there any way to do this -- in the context of a shell script and curl (note: not in a browser page with JS)?

like image 762
Greg Hendershott Avatar asked Jun 06 '14 15:06

Greg Hendershott


People also ask

How do I pull latest release from GitHub?

On GitHub.com, navigate to the main page of the repository. To the right of the list of files, click Releases. To copy a unique URL to your clipboard, find the release you want to link to, right click the title, and copy the URL. Alternatively, right click Latest Release and copy the URL to share it.

How do I download latest files from GitHub?

To download from GitHub, you should navigate to the top level of the project (SDN in this case) and then a green "Code" download button will be visible on the right. Choose the Download ZIP option from the Code pull-down menu. That ZIP file will contain the entire repository content, including the area you wanted.

What is GitHub releases Githubusercontent com?

The raw.githubusercontent.com domain is used to serve unprocessed versions of files stored in GitHub repositories. If you browse to a file on GitHub and then click the Raw link, that's where you'll go.


2 Answers

For releases that do not contain the version number or other variable content in their assets' names, you can use a URL of the format:

 https://github.com/owner/repository/releases/latest/download/ASSET.ext 

As per the docs:

If you'd like to link directly to a download of your latest release asset you can link to /owner/name/releases/latest/download/asset-name.zip.

like image 105
bb216b3acfd8f72cbc8f899d4d6963 Avatar answered Oct 04 '22 21:10

bb216b3acfd8f72cbc8f899d4d6963


Here is a way to do it w/o Github if you have a single download in the release:

wget $(curl -s https://api.github.com/repos/USERNAME/REPONAME/releases/latest | grep 'browser_' | cut -d\" -f4) 

It is pretty easy (though not pretty), and of course you can swap out wget for another curl call if you want to pipe it to something.

Basically, the curl call nets you a JSON structure, and I'm just using basic shell utilities to extract the URL to the download.

like image 44
The Real Bill Avatar answered Oct 04 '22 20:10

The Real Bill