英文:
build Golang release binaries for Github
问题
我正在寻找一些关于如何轻松构建适用于常见平台的二进制文件的想法,以便在Github上发布Golang项目。
我已经知道如何手动发布,可以使用Github的说明文档中的创建发布部分。目前我正在使用aktau/github-release进行发布,但这需要手动登录不同的机器(OSX、Linux、Windows)并进行发布。
Benedikt Lang在他的博客中介绍了使用Travis-CI(我还没有尝试过)。但我猜想公共的Travis只会为Linux构建二进制文件。
有什么建议吗?
英文:
I'm looking for ideas on how to easily build binaries for common platforms for a Golang project, for release on Github.
I already know how to manually do releases, using Github's instructions at Creating Releases. And I'm currently doing releases using aktau/github-release, but this requires manually logging into different machines (OSX, Linux, Windows) and doing the release.
Benedikt Lang has blogged about using Travis-CI (which I'm yet to experiment with). But I presume the public Travis will only build binaries for Linux.
Any suggestions?
答案1
得分: 4
你关于Travis CI只在Linux上构建的说法很可能是正确的,因为Go交叉编译需要从源代码构建和构建其他Go可执行文件。像RoninDev建议的那样,我建议你按照这篇博文设置自己的交叉编译构建环境:
http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
这非常简单,只需要大约10分钟的时间。在完成设置后,像Jenkins这样的构建工具将为你提供控制权,以启动所需平台(Mac、Windows、Linux等)的构建,然后为每个平台推送git发布版本。
英文:
You are most likely right about the Travis CI only building in Linux as go cross-compilation requires you to build from source and build other go executables. Like RoninDev suggested, I would suggest that you setup your own cross-compilation build environment by following the blog post:
http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
It is quite easy, and only takes about 10 minutes. After you have that, a build tool such as Jenkins will give you the controls to kick off a build for the desired platforms (Mac, Windows, Linux, etc) and then push out git releases for each one.
答案2
得分: 4
感谢提供的所有建议和答案。我正在寻找的是交叉编译,Dave Cheney的博客文章是一个很好的起点。
然而,我找到了一个更好的解决方案 - laher/goxc - "一个用于Go的构建工具,专注于交叉编译、打包和部署"。它受到了Dave Cheney的工作的启发,还包括了针对Github的部署工具 - 正是我所需要的。(例如,我用它来发布soniah/awsenv)
英文:
Thanks for all the suggestions and answers that were given. Cross-compilation was what I was looking for, and Dave Cheney's blog post was a good start.
However I found a better solution - laher/goxc - "a build tool for Go, with a focus on cross-compiling, packaging and deployment". It was inspired by Dave Cheney's work, and also includes deploy tools for Github - just what I was looking for. (For example, I used it to release soniah/awsenv)
答案3
得分: 2
我创建了goreleaser来做这个。
如果你想的话,可以试一下
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论