OpenCHAMI / smd

MIT License
0 stars 4 forks source link

Add Version Information #36

Closed alexlovelltroy closed 1 week ago

alexlovelltroy commented 1 week ago

It has been bugging me for a while that our builds don't embed the build environment into the compiled binaries. Go supports this with ldflags and goreleaser supports using environment variables with ldflags.

This PR adds a version.go file and two functions useful for printing the version information along with automation to build using goreleaser and the associated github action. The README is updated as well so that folks building locally can learn how to properly set the environment variables.

This PR also cleans up a few things in the goreleaser file to allow building for all architectures. The docker container remains amd64 only.

Output on Linux

❯ dist/smd_linux_amd64_v1/smd
Version: 2.16.2-next
Git Commit: be5275869d817290ae98e6907ff82222193f224b
Build Time: 1729880661
Git Branch: alexlovelltroy/add-version-info
Git Tag: v2.16.1
Git State: clean
Build Host: debian-11
Go Version: go1.23.2
Build User: alt

Output using docker:

❯ docker run ghcr.io/openchami/smd:latest
Version: 2.16.2-next
Git Commit: be5275869d817290ae98e6907ff82222193f224b
Build Time: 1729880661
Git Branch: alexlovelltroy/add-version-info
Git Tag: v2.16.1
Git State: clean
Build Host: debian-11
Go Version: go1.23.2
Build User: alt