diff --git a/Makefile b/Makefile index 20c2ac7..d3f7651 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ ARTEFACT=release/$(APPNAME)-$(GOOS)-$(GOARCH)$(EXT) # Extract version infos VERSION:=`git describe --tags` -LDFLAGS=-ldflags "-X $(AUTHOR)/$(APPNAME)/main.Version=${VERSION}" +LDFLAGS=-ldflags "-X main.Version=$(VERSION)" all: build @@ -44,7 +44,7 @@ clean: ## Build executable build: $(APPBASE)/$(APPNAME) -mkdir -p release - echo "Building: $(ARTEFACT) ..." + echo "Building: $(ARTEFACT) $(VERSION) ..." GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(LDFLAGS) -o $(ARTEFACT) .PHONY: build diff --git a/config.go b/config.go index c101f24..9178107 100644 --- a/config.go +++ b/config.go @@ -11,6 +11,7 @@ type Config struct { ListenAddr *string NbWorkers *int Debug *bool + Version *bool Timeout *int ScriptDir *string } @@ -19,6 +20,7 @@ var config = &Config{ ListenAddr: flag.String("listen", getEnv("LISTEN_ADDR", ":8080"), "HTTP service address (e.g.address, ':8080')"), NbWorkers: flag.Int("nb-workers", getIntEnv("NB_WORKERS", 2), "The number of workers to start"), Debug: flag.Bool("debug", getBoolEnv("DEBUG", false), "Output debug logs"), + Version: flag.Bool("version", false, "Output version"), Timeout: flag.Int("timeout", getIntEnv("HOOK_TIMEOUT", 10), "Hook maximum delay before timeout (in second)"), ScriptDir: flag.String("scripts", getEnv("SCRIPTS_DIR", "scripts"), "Scripts directory"), } diff --git a/main.go b/main.go index 0f0bb97..e6e1ba1 100644 --- a/main.go +++ b/main.go @@ -32,6 +32,11 @@ var ( func main() { flag.Parse() + if *config.Version { + fmt.Println(Version) + return + } + level := "info" if *config.Debug { level = "debug"