From a2a836c2a9fe42a5dc45cd2a267c3aa960b99e6e Mon Sep 17 00:00:00 2001 From: Roxie Gibson Date: Tue, 13 Jul 2021 23:47:47 +0100 Subject: [PATCH] feat: added version and makefile makefile allows for package variables to be defined --- Makefile | 5 +++++ cmd/abra/main.go | 5 ++++- version | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 version diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..e8e531c9 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +COMMIT := $(shell git rev-list -1 HEAD) +VERSION := $(shell cat ./version) + +run: + go run -ldflags="-X 'main.Commit=$(COMMIT)' -X 'main.Version=$(VERSION)'" ./cmd/abra \ No newline at end of file diff --git a/cmd/abra/main.go b/cmd/abra/main.go index 8ae11b5e..9382aac9 100644 --- a/cmd/abra/main.go +++ b/cmd/abra/main.go @@ -8,11 +8,14 @@ import ( "github.com/urfave/cli/v2" ) +var Version string +var Commit string + func main() { app := &cli.App{ Name: "abra", Usage: "The cooperative cloud utility belt 🎩🐇", - Version: "TBA", + Version: fmt.Sprintf("%s-%s", Version, Commit[:7]), Commands: []*cli.Command{ { Name: "server", diff --git a/version b/version new file mode 100644 index 00000000..fbc1e623 --- /dev/null +++ b/version @@ -0,0 +1 @@ +1.0.0a \ No newline at end of file