Releasing Go applications via Homebrew.
A good application will have a good release strategy.
Release Strategy ??
Suppose you are given the task of deploying a small solution in your firm which does functionality X.
Let X = functionality to generate boilerplate code for a project which can be used by other software developers.
This solution will save a lot of time for the other developers who want to set up a similar project from scratch.
How can you ensure that other developers directly use the solution without any configuration changes or installation headaches?
A simple option is to publish the solution as a binary (.exe in windows). This binary should run on various platforms like Windows, macOS, Linux. Factors like the CPU architecture (x86, ARM) should also be considered before releasing the binary to a wider audience.
The Solution: GoReleaser
For Go projects, there is an amazing tool known as GoReleaser. While Goreleaser helps in releasing Go applications via Docker, GitHub Actions etc, for this blog we will only concentrate on releasing the binaries to Homebrew to satisfy our requirement.
A sample template of GoReleaser to release to Homebrew is at following link. The gist has comments as well:
brew install goreleaser
Add GoReleaser yml
This adds a .goreleaser.yml file in the root directory of the project.
GoReleaser requires a new tag before publishing. Hence make sure the commit is tagged by using the following commands.
Tag a Release
git tag -a v0.1.0 -m "First release" git push origin v0.1.0 //Note that git needs to be installed for the above commands to work
If GoReleaser needs to be tested for configurations without tagging and publishing it into Github use the following command
goreleaser --snapshot --skip-publish --rm-dist
Also don't forget to export your GITHUB_TOKEN or GITLAB_TOKEN as environment variables
To release a software package using GoReleaser, just type in the following command and it should push it to Homebrew. That's it!!!
Release a Go Binary
Remember, while pushing the package to Homebrew it creates a ruby file which is automatically added .
This post taught you how to create a small application in GO and release it via Homebrew .
Other developers in the firm can now install this application from Homebrew without knowing how this needs to be installed and what is inside.
We have a created a simple solution to the above problem statement and named the framework as Autobots. Autobots uses GoReleaser to release the binary to Homebrew. Take a look at our project at :
Join the conversation