I\'d like to have \"Download Latest Version\" button on my website which would represent the link to the latest release (stored at GitHub Releases
If you using PHP try follow code:
function getLatestTagUrl($repository, $default = 'master') {
$file = @json_decode(@file_get_contents("https://api.github.com/repos/$repository/tags", false,
stream_context_create(['http' => ['header' => "User-Agent: Vestibulum\r\n"]])
));
return sprintf("https://github.com/$repository/archive/%s.zip", $file ? reset($file)->name : $default);
}
Function usage example
echo '<a href="' .getLatestTagUrl('OzzyCzech/vestibulum') .'">Download</a>';
You can use the following where:
curl -L https://api.github.com/repos/${Organization}/${Repository}/tarball > ${Repository}.tar.gz
The top level directory in the .tar.gz file has the sha hash of the commit in the directory name which can be a problem if you need an automated way to change into the resulting directory and do something.
The method below will strip this out, and leave the files in a folder with a predictable name.
mkdir ${Repository}
curl -L https://api.github.com/repos/${Organization}/${Repository}/tarball | tar -zxv -C ${Repository} --strip-components=1