如何使用脚本在GitHub上发布构建工件资产? [英] How to release a build artifact asset on GitHub with a script?

查看:56
本文介绍了如何使用脚本在GitHub上发布构建工件资产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出一个在GitHub上生成构建的单命令过程.

I am trying to figure out a one-command process for generating a build on GitHub.

我期望做的是运行某种命令-make release,然后make release脚本构建发布工件,然后以某种方式将其上传到GitHub.

What I anticipate doing is running some sort of command- make release, say, and the make release script builds up the release artifact and then uploads it to GitHub in some fashion.

但是,我对如何在GitHub上实际获得发布工件感到困惑.源代码很棒,但并非每个人都希望自己构建. :-)

However, I'm fairly confused about how to actually get a release artifact on GitHub. Source code is awesome, but not everyone wants to do their own builds. :-)

推荐答案

2013年9月更新,您可以自动化发布(处于预览模式的API )

2014年1月更新,其中有一个名为 github发行 rel ="noreferrer"> Nicolas Hillegeer(aktau),用于创建发行版并上传(二进制)工件.
它使用上面提到的新的github版本API.查看项目的 Makefile ,以了解如何更自动化

Update January 2014, there's an unofficial command-line app, called github-release by Nicolas Hillegeer (aktau), for creating releases and uploading (binary) artifacts.
It uses the new github releases API mentioned above. Look at the Makefile of the project to see how to automate it more still.

示例:

# create a formal release
$ github-release release \
    --user aktau \
    --repo gofinance \
    --tag v0.1.0 \
    --name "the wolf of source street" \
    --description "Not a movie, contrary to popular opinion. Still, my first release!" \
    --pre-release


由于二进制资产,此API略有不同.请求发布资产时,我们使用Accept标头进行内容协商.
传递标准API媒体类型以获取API表示形式:

This API is a little different due to the binary assets. We use the Accept header for content negotation when requesting a release asset.
Pass a standard API media type to get the API representation:

$ curl -i -H "Authorization: token TOKEN" \
     -H "Accept: application/vnd.github.manifold-preview" \
     "https://uploads.github.com/repos/hubot/singularity/releases/assets/123"

HTTP/1.1 200 OK

{
  "id": 123,
...
}

传递"application/octet-stream"以下载二进制内容.

Pass "application/octet-stream" to download the binary content.

$ curl -i -H "Authorization: token TOKEN" \
     -H "Accept: application/octet-stream" \
     "https://uploads.github.com/repos/hubot/singularity/releases/assets/123"

HTTP/1.1 302 Found

上传是通过对配套"uploads.github.com"服务的单个请求来处理的.

Uploads are handled by a single request to a companion "uploads.github.com" service.

$ curl -H "Authorization: token TOKEN" \
     -H "Accept: application/vnd.github.manifold-preview" \
     -H "Content-Type: application/zip" \
     --data-binary @build/mac/package.zip \
     "https://uploads.github.com/repos/hubot/singularity/releases/123/assets?name=1.0.0-mac.zip"


2013年7月2日更新,您现在可以定义发布了.


Update 2d July 2013, you now can define a release.

  • 发布中随附发行说明和下载软件或源代码的链接.
  • 遵循许多Git项目的约定,发行版与Git标签相关.您可以使用现有标签,也可以让发布版本在发布标签时创建标签.
  • 您还可以将二进制资产(例如编译后的可执行文件,缩小的脚本,文档)附加到发行版中.一旦发布,所有可以查看版本库的人都可以使用发行详细信息和资产.
  • Releases are accompanied by release notes and links to download the software or source code.
  • Following the conventions of many Git projects, releases are tied to Git tags. You can use an existing tag, or let releases create the tag when it's published.
  • You can also attach binary assets (such as compiled executables, minified scripts, documentation) to a release. Once published, the release details and assets are available to anyone that can view the repository.

这是替换旧的二进制上传服务(即

make release脚本构建了发布工件,然后以某种方式将其上传到github.

the make release script builds up the release artifact and then uploads it to github in some fashion.

这意味着将其(它"是由一个或几个文件组成的交付文件,通常包括二进制文件)添加到常规本地存储库中,然后将该存储库推送到与其匹配的GitHub存储库中.

That would mean adding it ("it" being the delivery made of one or several files, generally including binaries) to a regular local repo, and then pushing that repo to its matching GitHub repo.

话虽如此,之所以没有在任何发布"任务中提及GitHub,是因为Git是一个 source 控制管理系统,并且不适用于二进制文件.

That being said, the reason GitHub isn't mention in any "release" task is because Git is a source control management system, and is ill-suited for binaries.

它当然可以具有那些文件(二进制文件),但由于要在一段时间后使存储库过大而无法定期存储这些文件(二进制文件):每次克隆都将花费越来越长的时间.
请参见
什么是Git限制,以及"git-如果源文件和存储库位于同一台机器?".

It can have those files (binaries) of course, but isn't made to have them regularly, because of the bloated size of the repo after a while: each cloning would take longer and longer.
See What are the Git limits, and also "git - should source files and repository be on the same machine ?".

这篇关于如何使用脚本在GitHub上发布构建工件资产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆