How to setup travis-ci with goreleaser for automated binary golang releases

I have been enjoying writing golang applications for a few years now, and I naively assumed other people who wanted to use them could easily build the apps with instructions I provided easy enough.

I discovered that the differences between operating systems is enough that compiling the applications can be burdensome for others. My buddy @slm (hes kind of a big deal) mentioned I should check out goreleaser and I am glad I did.

I was able to setup a release pretty quickly with it and got this pretty page with compiled builds for mac, windows, and linux (including rpm and deb). Here is how I did it.

Step 1. Sign up for travis-ci (its free for opensource projects, choose the right license for your project)

Step 2. Link and authorize it for your projects (travis will walk you through this)

Step 3. Add a api token for goreleaser, to allow it to update your repo with binary builds and notes. I followed this guide https://goreleaser.com/environment/

Step 4. Add the .travis.yml and .goreleaser.yml and configure them to do what you want. You can checkout my examples on the https://github.com/Jmainguy/k8sCapcity project.

Step 5. Cut a release,

$ git tag -a v0.1.0 -m “First release”

$ git push origin v0.1.0

Watch travis spin on your new release, and then see the updated contents. Thank you goreleaser and travis-ci for your great projects.