From 957fa78711ba61ee33f885572128dd9dc96a21e8 Mon Sep 17 00:00:00 2001 From: Sam Morris Date: Wed, 24 Feb 2016 01:40:17 +0000 Subject: [PATCH] Specify program version at build time The version string is obtained by running `git describe` rather than being hardcoded in `strings.go`. --- Makefile | 2 +- main.go | 2 +- strings.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 8a64228..896d2eb 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ mumbledj: main.go commands.go parseconfig.go strings.go service.go youtube_dl.go go get github.com/karmakaze/goop rm -rf Goopfile.lock goop install - goop go build -o mumbledj + goop go build -o mumbledj -ldflags '-X strings.VERSION $(shell git describe --tags --dirty)' clean: rm -f mumbledj* diff --git a/main.go b/main.go index 53f843b..6a84f91 100644 --- a/main.go +++ b/main.go @@ -214,7 +214,7 @@ func main() { flag.Parse() if version { - fmt.Printf("MumbleDJ %s\n", VERSION) + fmt.Printf("MumbleDJ v%s\n", VERSION) os.Exit(0) } diff --git a/strings.go b/strings.go index 1a56ec8..e796e3d 100644 --- a/strings.go +++ b/strings.go @@ -8,10 +8,10 @@ package main // Current version of the bot -const VERSION = "v2.8.15" +var VERSION = "Unknown" // Message shown to users when they request the version of the bot -const DJ_VERSION = "MumbleDJ " + VERSION + "" +var DJ_VERSION = "MumbleDJ v" + VERSION + "" // Message shown to users when the bot has an invalid API key. const INVALID_API_KEY = "MumbleDJ does not have a valid %s API key."