diff options
author | Dan Duvall <dduvall@wikimedia.org> | 2017-10-16 09:47:43 -0700 |
---|---|---|
committer | Dan Duvall <dduvall@wikimedia.org> | 2017-10-18 14:46:15 -0700 |
commit | d53a06a138106c1652fff0b8576ae907a29a727c (patch) | |
tree | 4e9ec388de0effbd1752a030d34aec0737df3f3c /meta | |
parent | 01f3533a0b4819ce868d4f89c83a090eae6cfd08 (diff) | |
download | blubber-d53a06a138106c1652fff0b8576ae907a29a727c.tar.gz |
Capture and expose build-time meta data
Summary:
The `go build` tool can accept linker options that dynamically set
variable values at build time. Let's make use of that in our `Makefile`
and `debian/rules` to know and expose meta data such as version and Git
commit at runtime.
Test Plan:
Run `make bin/blubber && bin/blubber --version` and verify that it outputs
"0.0.1-[git head commit]". Build and install the debian package and verify
the same using the installed binary.
Reviewers: thcipriani, hashar, Joe, #release-engineering-team
Reviewed By: thcipriani, #release-engineering-team
Tags: #release-engineering-team
Differential Revision: https://phabricator.wikimedia.org/D816
Diffstat (limited to 'meta')
-rw-r--r-- | meta/meta.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/meta/meta.go b/meta/meta.go new file mode 100644 index 0000000..a5ee581 --- /dev/null +++ b/meta/meta.go @@ -0,0 +1,13 @@ +package meta + +// Meta variables set dynamically by the linker at build time +var ( + Version string + GitCommit string +) + +// FullVersion returns the version string in the form of +// ([major].[minor].[patch]+[commit]) +func FullVersion() string { + return Version + "+" + GitCommit +} |