Compile and release a Go application
Using Codefresh pipelines
Goreleaser is a helper utility that allows you to easily create:
- Binary packages for each OS/arch
- Github releases
- Docker images
for Go applications.
Codefresh can also create Docker images on its own, but goreleaser is still useful for the binary artifact creation capability.
Run goreleaser with docker
You can see the example project at https://github.com/codefresh-contrib/goreleaser-sample-app. The repository contains a simple Golang web application with a goreleaser configuration
More typically however you also need to provide a GIThub token so that github releases are also available. There are two ways to do that.
Create a CI pipeline that compiles/releases Go
Here we use cf_export and the codefresh CLI in order to ask Codefresh about the existing token (that was used in git integrations). In your case you need to change
github-1 with the name of your Github integration.
It also possible to pass a GITHUB_TOKEN directly in the pipeline, if you don’t want to re-use the existing one. This is an alternative way of allowing goreleaser to create github releases.
You could also store the token in shared configuration. Regardless of the way you choose to pass the Github token, the final step is to make sure that your pipeline is only executed for tag events.
This means that this pipeline will not run on normal commits. It is also possible to use step conditionals for more complex cases.