summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--version.go13
2 files changed, 17 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 2ae2e86..3e638f7 100644
--- a/Makefile
+++ b/Makefile
@@ -2,14 +2,16 @@ TARGET_EXEC := ceres
BUILD_DIR := ./build
MODULE_NAME := xengineering.eu/ceres
+VERSION := $(shell git describe --dirty --always)
+
all: $(BUILD_DIR)/$(TARGET_EXEC)
$(BUILD_DIR)/$(TARGET_EXEC):
- go build -o $@ $(MODULE_NAME)
+ go build -ldflags "-X main.gitDescribe=$(VERSION)" -o $@ $(MODULE_NAME)
.PHONY: debug
debug:
- go run $(MODULE_NAME)
+ go run -ldflags "-X main.gitDescribe=$(VERSION)" $(MODULE_NAME)
.PHONY: clean
clean:
diff --git a/version.go b/version.go
new file mode 100644
index 0000000..c3cc266
--- /dev/null
+++ b/version.go
@@ -0,0 +1,13 @@
+package main
+
+import "fmt"
+
+var gitDescribe string
+
+func version() (string, error) {
+ if gitDescribe == "" {
+ return "", fmt.Errorf("No version information available")
+ }
+
+ return gitDescribe, nil
+}