简体   繁体   English

使用 wget/curl 下载 Github 构建工件(发布)

[英]Download Github build artifact (release) using wget/curl

The Goal: Download github release tar.gz in Docker Build Script, so that the release files can be used for the docker image.目标:在Docker Build Script中下载github release tar.gz,以便发布文件可以用于docker镜像。 I do not want the full source downloaded, which I can get to download through the archive path using the tag, but rather a build artifact that is part of the release.我不希望下载完整的源代码,我可以使用标签通过存档路径下载它,而是下载作为版本一部分的构建工件。

To Be Noted: This is a download from a private repository, which is why I'm attempting to send my github_token as part of the command currently.需要注意的是:这是从私人存储库下载的,这就是为什么我试图将我的 github_token 作为当前命令的一部分发送。

The Problem: I'm having trouble downloading a github release tar.gz using wget.问题:我在使用 wget 下载 github 版本 tar.gz 时遇到问题。

wget --header="Authorization: token <GITHUB_TOKEN>" --output-document=<FILENAME>.tar.gz https://github.com/<USER>/<REPO>/releases/download/<TAG>/<FILENAME>.tar.gz

This is returning the following error:这将返回以下错误:

--2014-12-02 16:19:25--  https://github.com/<USER>/<REPO>/releases/download/<TAG>/<FILENAME>.tar.gz
Resolving github.com (github.com)... 192.30.252.131, 192.30.252.131
Connecting to github.com (github.com)|192.30.252.131|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2014-12-02 16:19:25 ERROR 404: Not Found.

It's worth noting that I'm not opposed to using curl for the download either or some other solution if necessary.值得注意的是,我不反对使用 curl 进行下载或在必要时使用其他解决方案。

You can use the GitHub API.您可以使用 GitHub API。

To download a release using wget, you can do:要使用 wget 下载版本,您可以执行以下操作:

wget --header "Authorization: token <GITHUB TOKEN>"  --output-document=<RELEASE>.tar.gz https://api.github.com/repos/<USER>/<REPO>/tarball/<RELEASE NAME>

Use can change tarball to zipball to get a zip file.使用可以将tarball更改为zipball以获取 zip 文件。

The release.tar.gz part is set by the owner, so it is not generic. release.tar.gz部分是由所有者设置的,因此它不是通用的。

$ wget https://github.com/XhmikosR/notepad2-mod/releases/download/4.2.25.935/Notepad2-mod.4.2.25.935.exe
--2014-12-02 11:16:42--  https://github.com/XhmikosR/notepad2-mod/releases/download/4.2.25.935/Notepad2-mod.4.2.25.935.exe
Resolving github.com (github.com)... 192.30.252.130
Connecting to github.com (github.com)|192.30.252.130|:443... connected.
HTTP request sent, awaiting response... 302 Found

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM