💾 Archived View for capsule.adrianhesketh.com › 2016 › 09 › 08 › releasing-versioned-go-apps-from-tr… captured on 2023-04-26 at 13:21:41. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

-=-=-=-=-=-=-

capsule.adrianhesketh.com

home

Releasing Versioned Go Apps From Travis

So, thanks to Redditor vruin, I learned that there's an easier way to add a version number than what I was doing:

https://www.atatus.com/blog/golang-auto-build-versioning/

The way described in the blog post uses the `-ldflags` `go build` parameter instead of my relatively convoluted approach of using `go generate` to create a version.go file. I just needed to make a couple of changes to the version scheme to make it work for me:

GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=`git describe --tags --long`" -o release/terminator

The next thing I needed to do was to package up those builds and push them back out to Github. I followed some excellent instructions, just making a few changes to take out the need for a `make` file:

https://loads.pickle.me.uk/2015/08/22/easy-peasy-github-releases-for-go-projects-using-travis/

I've put this into practice on my "Terminator" application at [0] and I'm now confident I can deploy new distributions of my applications automatically.

[0]

More

Next

Immutable Windows Infrastructure on AWS

Previous

Adding a Version Number to Go Packages with `go generate`

Home

home