的最新版本的GitHub

的最新版本的GitHub

本文介绍了_download file_的最新版本的GitHub URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然这个问题与类似,但它实际上不同的 - 这是一个链接,意思是下载文件本身的最新版本。



GitHub提供了一个重定向到信息的最新URL页面获取最新版本。例如:将重定向到(因为我输入了这个;或者在某一天更新版本的页面)。



这很棒,但我需要一个URL 下载文件本身。在此示例中,与绿色下载按钮关联的.zip文件(当我输入这个;或者更新的zip文件,有一天)。



为什么?我想给这个URL添加curl作为Travis CI脚本的一部分,以下载最新版本。



我猜想几个URL / releases / download / latest /file.zip(用latest代替版本部分)和/releases/download/file.zip,而是那些404。

有没有办法做到这一点 - 在shell脚本和curl的上下文中(注意:在浏览器页面中使用JS的 not )?

使用git 。



最初是我的.travis。 yml就像这样:

  before_install:
- curl -L https://raw.githubusercontent.com/greghendershott /travis-racket/master/install-racket.sh | bash

这将自动从回购协议中获得最新版本。



但有人向我指出,GitHub不希望人们使用 raw.github.com 进行下载。相反,人们应该使用发布。所以我是一个很好的doob,每次都手动发布。然后我的.travis.yml就像这样:

  before_install:
- curl -L https:// github。 com / greghendershott / travis-racket / releases / download / v0.6 / install-racket.sh | bash

但是每次发布版本都是PITA。更糟糕的是,所有的.travis.yml文件都需要更新,以指向文件的新版本。



相反,只需使用git来克隆repo,然后使用其中的文件:

  before_install:
- git clone https://github.com/greghendershott/travis- racket.git
- cat travis-racket / install-racket.sh | bash#管道bash不sh!


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)?

解决方案

As @florianb pointed out, I should use git.

Originally my .travis.yml was something like:

before_install:
- curl -L https://raw.githubusercontent.com/greghendershott/travis-racket/master/install-racket.sh | bash

This would automatically get whatever the latest version is, from the repo.

But someone pointed out to me that GitHub doesn't want people to use raw.github.com for downloads. Instead people should use "releases". So I was a good doob and manually made a release each time. Then my .travis.yml was something like:

before_install:
- curl -L https://github.com/greghendershott/travis-racket/releases/download/v0.6/install-racket.sh | bash

But it's a PITA to make a release each time. Worse, all .travis.yml files need to be updated to point to the newer version of the file.

Instead -- just use git to clone the repo, and use the file within it:

before_install:
- git clone https://github.com/greghendershott/travis-racket.git
- cat travis-racket/install-racket.sh | bash # pipe to bash not sh!

这篇关于_download file_的最新版本的GitHub URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 21:21