diff --git a/Makefile b/Makefile index aaacb8d..78e1670 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,36 @@ SOURCE = $(wildcard *.go) +TAG ?= $(shell git describe --tags) +GOBUILD = go build -ldflags '-w' + ALL = $(foreach suffix,win.exe linux osx,\ build/webhooker-$(suffix)) all: $(ALL) +clean: + rm -f $(ALL) + +test: + go test + cram tests/cram.t + win.exe = windows osx = darwin build/webhooker-%: $(SOURCE) @mkdir -p $(@D) CGO_ENABLED=0 GOOS=$(firstword $($*) $*) GOARCH=amd64 go build -o $@ -upload: $(ALL) -ifndef UPLOAD_PATH - @echo "Define UPLOAD_PATH to determine where files should be uploaded" +release: $(ALL) +ifndef desc + @echo "Run it as 'make release desc=tralala'" else - rsync -l -P $(ALL) $(UPLOAD_PATH) + github-release release -u piranha -r webhooker -t "$(TAG)" -n "$(TAG)" --description "$(desc)" + @for x in $(ALL); do \ + echo "Uploading $$x" && \ + github-release upload -u piranha \ + -r webhooker \ + -t $(TAG) \ + -f "$$x" \ + -n "$$(basename $$x)"; \ + done endif - -test: - go test - cram tests/cram.t diff --git a/tests/cram.t b/tests/cram.t index 93d2b46..1efd6ac 100755 --- a/tests/cram.t +++ b/tests/cram.t @@ -47,6 +47,7 @@ Usage: -l, --log= path to file for logging -c, --config= read rules from this file -d, --dump dump rules to console + -V, --version show version and exit --help show this help message Check that it works: diff --git a/webhooker.go b/webhooker.go index 2093ea5..2f1d9a4 100644 --- a/webhooker.go +++ b/webhooker.go @@ -17,15 +17,16 @@ import ( /// Globals -var Version = "0.1" +var Version = "0.2" var opts struct { - Interface string `short:"i" long:"interface" default:"" description:"ip to listen on"` - Port string `short:"p" long:"port" default:"8000" description:"port to listen on"` - Log string `short:"l" long:"log" description:"path to file for logging"` - Config string `short:"c" long:"config" description:"read rules from this file"` - Dump bool `short:"d" long:"dump" description:"dump rules to console"` - ShowHelp bool `long:"help" description:"show this help message"` + Interface string `short:"i" long:"interface" default:"" description:"ip to listen on"` + Port string `short:"p" long:"port" default:"8000" description:"port to listen on"` + Log string `short:"l" long:"log" description:"path to file for logging"` + Config string `short:"c" long:"config" description:"read rules from this file"` + Dump bool `short:"d" long:"dump" description:"dump rules to console"` + Version bool `short:"V" long:"version" description:"show version and exit"` + ShowHelp bool ` long:"help" description:"show this help message"` } /// Core interfaces