Download latest GitHub release

前端 未结 8 1873
心在旅途
心在旅途 2020-12-03 03:36

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

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-03 03:46

    You don't need any scripting to generate a download link for the latest release. Simply use this format:

    https://github.com/:owner/:repo/zipball/:branch
    

    Examples:

    https://github.com/webix-hub/tracker/zipball/master
    https://github.com/iDoRecall/selection-menu/zipball/gh-pages
    

    If for some reason you want to obtain a link to the latest release download, including its version number, you can obtain that from the get latest release API:

    GET /repos/:owner/:repo/releases/latest
    

    Example:

    $.get('https://api.github.com/repos/idorecall/selection-menu/releases/latest', function (data) {
      $('#result').attr('href', data.zipball_url);
    });
    
    Download latest release (.ZIP)

提交回复
热议问题