commit 1e15ae5c0d188ddee153e7f72d983d31e01495c9
parent 3157d714f22e866924ddbd4dd838653c595d7187
Author: Paco Esteban <paco@onna.be>
Date: Fri, 2 Jun 2017 11:05:17 +0200
New Makefile and versioning system to distribute easily
Diffstat:
4 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1 @@
+build
diff --git a/Makefile b/Makefile
@@ -0,0 +1,44 @@
+#
+# Makefile
+# Paco Esteban, 2017-06-01 18:03
+#
+
+BINARY=duckdnsrefresh
+
+VERSION=$(shell cat VERSION)
+BUILD=`git rev-parse --short HEAD`
+
+LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"
+
+.DEFAULT: build
+
+build:
+ mkdir -p ./build
+ go build ${LDFLAGS} -o ./build/${BINARY}
+
+xc_%:
+ mkdir -p ./build
+ $(eval SUFFIX=$(suffix $@))
+ @echo "Cros compiling for: $(basename $*) $(SUFFIX:.%=%)"
+ GOOS=$(basename $*) GOARCH=$(SUFFIX:.%=%) CGO_ENABLE=0 \
+ go build ${LDFLAGS} -o \
+ ./build/${BINARY}-${VERSION}-$(basename $*)-$(SUFFIX:.%=%)
+
+buildall: xc_linux.386 xc_linux.amd64 xc_linux.arm\
+ xc_openbsd.386 xc_openbsd.amd64 \
+ xc_freebsd.386 xc_freebsd.amd64 \
+ xc_darwin.amd64 \
+ sign
+sign:
+ @echo "singing in the rain"
+ cd ./build && \
+ sha256sum * > SHA256 && \
+ gpg --armor --detach-sign SHA256
+
+clean:
+ rm -rf ./build/*
+
+.PHONY: clean build buildall sign
+
+# vim:ft=make
+#
diff --git a/VERSION b/VERSION
@@ -0,0 +1 @@
+0.1
diff --git a/main.go b/main.go
@@ -13,6 +13,7 @@ import (
"io/ioutil"
"log"
"net/http"
+ "os"
"github.com/spf13/viper"
)
@@ -20,11 +21,19 @@ import (
var (
token string
domains []string
+ Version string
+ Build string
)
func main() {
var v = flag.Bool("v", false, "Enable verbose output")
+ var ver = flag.Bool("V", false, "Shows version and exists")
flag.Parse()
+
+ if *ver {
+ fmt.Printf("Version: %s. Build: %s\n", Version, Build)
+ os.Exit(0)
+ }
viper.SetConfigName("config") // name of config file (without extension)
viper.AddConfigPath("/etc/duckdns/") // path to look for the config file in
viper.AddConfigPath("$HOME/.duckdns") // call multiple times to add many search paths