From bcfbad42b66aa29f85b283dc9aed362d3ff97f84 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Tue, 18 Apr 2017 16:07:54 +0200 Subject: [PATCH] Add version and build number output --- .gitignore | 2 +- Makefile | 11 +++++++++++ boardvoting.go | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 146c03e..79c64c5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,6 @@ *.pem .*.swp .idea/ -cacert-board_vote +cacert-boardvoting config.yaml database.sqlite diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..857255e --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +VERSION := $(shell git describe --always --dirty=-dev) +BUILD := $(shell date --iso-8601=seconds --utc) +GOFILES := $(wildcard *.go) + +cacert-boardvoting: ${GOFILES} + go build -o $@ -ldflags "-X 'main.version=${VERSION}' -X 'main.build=${BUILD}'" + +clean: + rm -f cacert-boardvoting + +.PHONY: clean diff --git a/boardvoting.go b/boardvoting.go index c467b40..8ad5438 100644 --- a/boardvoting.go +++ b/boardvoting.go @@ -23,6 +23,8 @@ import ( var logger *log.Logger var config *Config var store *sessions.CookieStore +var version = "undefined" +var build = "undefined" const sessionCookieName = "votesession" @@ -407,6 +409,8 @@ func init() { } func main() { + logger.Printf("CAcert Board Voting version %s, build %s\n", version, build) + var err error db, err = sqlx.Open("sqlite3", config.DatabaseFile) if err != nil {