diff --git a/Makefile b/Makefile index 90f1f99..5652ead 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,23 @@ +VERSION ?= $(shell git describe --tags 2>/dev/null) +ifeq "$(VERSION)" "" + VERSION := UNKNOWN +endif .PHONY: \ - all + all \ + test all: bin/pomo clean: - rm -v bin/pomo bindata.go + rm -v bin/* 2> /dev/null || true bindata.go: go-bindata -pkg main -o $@ tomato-icon.png +test: + go test ./... + bin/pomo: bindata.go - mkdir bin 2>/dev/null - go build -o bin/pomo + @echo mkdir bin 2>/dev/null || true + go build -ldflags "-X main.Version=$(VERSION)" -o bin/pomo diff --git a/main.go b/main.go index 9b02488..4669ba7 100644 --- a/main.go +++ b/main.go @@ -97,7 +97,7 @@ func main() { var ( path = app.StringOpt("p path", defaultConfigPath(), "path to the pomo config directory") ) - app.Version("v version", version) + app.Version("v version", Version) app.Command("start s", "start a new task", start(path)) app.Command("init", "initialize the sqlite database", initialize(path)) app.Command("list l", "list historical tasks", list(path)) diff --git a/version.go b/version.go index 2eddb8a..3cb07c8 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package main -var version = "undefined" +var Version = "undefined"