[英]Simple .gitlab-ci.yml file for compiling a Go binary
The module name in my go.mod
file is gitlab.com/mycorp/mycomp/data/hubpull
我的go.mod
文件中的模块名称是gitlab.com/mycorp/mycomp/data/hubpull
The 3 files go.mod go.sum main.go
are all in the same outermost folder of my project. 3 个文件go.mod go.sum main.go
都在我项目的同一个最外层文件夹中。 I have been using these two commands manually on local to compile:我一直在本地手动使用这两个命令进行编译:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main main.go
zip main.zip main
Now I need a gitlab CI file to build a binary based on the above 2 commands.现在我需要一个 gitlab CI 文件来构建基于上述 2 个命令的二进制文件。 I tried searching but a lot of the examples don't work.我试过搜索,但很多例子都不起作用。
Maybe you have already tried it, but this is the best simple build CI file for go.也许您已经尝试过,但这是 go 的最佳简单构建 CI 文件。
image: golang:alpine
stages:
- build
go_build:
stage: build
script:
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main main.go
- zip main.zip main
artifacts:
paths:
- main.zip
There are more you could add like lint, test, etc (refer this -> https://about.gitlab.com/blog/2017/11/27/go-tools-and-gitlab-how-to-do-continuous-integration-like-a-boss/ )您还可以添加更多内容,例如 lint、测试等(请参阅此 -> https://about.gitlab.com/blog/2017/11/27/go-tools-and-gitlab-how-to-do-continuous -像老板一样整合/ )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.