我想让“下载最新版本”的按钮出现在我的网站上,它代表到最新版本的链接(存储在GitHub Releases上)。我试图创建名为“最新”的发布标记,但当我尝试加载新版本(与标记创建日期混淆、标记互换等)时,它变得复杂起来。手动更新我网站上的下载链接也是一项耗费时间和谨慎的任务.我看到了唯一的方法-将所有下载按钮重定向到一些html,这反过来将重定向到实际的最新版本。
请注意,我的网站是托管在GitHub页面(静态托管),所以我只是不能使用服务器端脚本生成链接。有什么想法吗?
发布于 2014-03-19 13:26:56
Github现在在项目的发布页面()上提供了一个“最新版本”按钮,您已经创建了第一个发布版。
在您提供的示例中,此按钮链接到https://github.com/reactiveui/ReactiveUI/releases/latest
发布于 2015-09-01 21:02:54
您不需要任何脚本来为最新版本生成下载链接。只需使用以下格式:
https://github.com/:owner/:repo/zipball/:branch示例:
https://github.com/webix-hub/tracker/zipball/master
https://github.com/iDoRecall/selection-menu/zipball/gh-pages如果出于某种原因,您希望获得到最新版本下载的链接,包括其版本号,则可以从获取最新版本API获得该链接。
GET /repos/:owner/:repo/releases/latest示例:
$.get('https://api.github.com/repos/idorecall/selection-menu/releases/latest', function (data) {
$('#result').attr('href', data.zipball_url);
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a id="result">Download latest release (.ZIP)</a>
发布于 2015-02-18 21:41:26
从2015年2月18日开始,GitHUb V3发布API就有一个获取最新版本API。
GET /repos/:owner/:repo/releases/latest也见"链接到释放“。
不过,资产的名称可能很棘手。
例如,Git for Windows需要如下命令:
curl -IkLs -o NUL -w %{url_effective} \
https://github.com/git-for-windows/git/releases/latest|\
grep -o "[^/]*$"| sed "s/v//g"|\
xargs -I T echo \
https://github.com/git-for-windows/git/releases/download/vT/PortableGit-T-64-bit.7z.exe \
-o PortableGit-T-64-bit.7z.exe| \
sed "s/.windows.1-64/-64/g"|sed "s/.windows.\(.\)-64/.\1-64/g"|\
xargs curl -kL前3行提取最新版本的2.35.1.windows.2
其余的将构建正确的URL
https://github.com/git-for-windows/git/releases/download/
v2.35.1.windows.2/PortableGit-2.35.1.2-64-bit.7z.exe
^^^^^^^^^^^^^^^^^ ^^^^^^^^^https://stackoverflow.com/questions/21439239
复制相似问题