Download latest GitHub release

前端 未结 8 1901
心在旅途
心在旅途 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 04:08

    You can use the following where:

    • ${Organization} as the GitHub user or organization
    • ${Repository} is the repository name

    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

提交回复
热议问题