Build, test, and release Go projects with GitHub Actions

After a couple weeks of waiting I was finally accepted into the private beta of GitHub Actions, which allows you to automate software workflows including CI/CD straight from GitHub. While I anticipate using this for all sorts of future projects, I have a particular Go project on GitHub that I knew was a perfect candidate for testing out Actions.

The project is a command line tool written in Go that provides commands for common server tasks. Along with linting and running unit tests, I have also been building the binary for multiple architectures and uploading the artifacts by hand for every release. With GitHub Actions, I was able to automate all of this such that opening pull requests triggers automated tests and builds, while pushing a new tag uses GoReleaser to automatically build and upload binaries for multiple architectures straight into the release. This is beyond cool and thanks to Building a basic CI/CD pipeline for a Golang application using GitHub Actions by Bruno Paz I was able to set it all up with minimal effort.

I did come across one hiccup which was that GoReleaser checks the project root for a main function by default, but my main lives in a different directory. The solution was to create a .goreleaser.yaml configuration file and pass it to the goreleaser command in my Actions workflow.

I'm really looking forward to building more complex workflows with GitHub Actions in the future and am already impressed with how intuitive and powerful even the simplest of workflows can be.

Show Comments