diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..ece61c6 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.6 \ No newline at end of file diff --git a/main.go b/main.go index a06919d..1212021 100644 --- a/main.go +++ b/main.go @@ -25,8 +25,8 @@ import ( "github.com/janeczku/go-dnsmasq/server" ) -// var Version string -const Version = "1.0.5" +// set at build time +var Version = "dev" var ( nameservers = []string{} diff --git a/scripts/build b/scripts/build index a2c840d..9f2f2e0 100755 --- a/scripts/build +++ b/scripts/build @@ -1,6 +1,14 @@ #!/bin/bash set -e +if [ -z "$1" ]; then + echo "The version number must be passed to this script" + exit 1 +fi +VERSION=$1 + +echo "building binary $VERSION" + BUILD_IMAGE_NAME="go-dnsmasq-build" # GOARCH=${GOARCH:-"386 amd64 arm"} GOOS=${GOOS:-"darwin linux"} @@ -23,6 +31,6 @@ docker run --rm \ -os "$GOOS" \ -arch "$GOARCH" \ -output="go-dnsmasq_{{.OS}}-{{.Arch}}" \ - -ldflags="-w -s" \ + -ldflags "-w -s -X main.Version=$VERSION" \ -tags="netgo" \ -rebuild diff --git a/scripts/build-min b/scripts/build-min index 8355579..1e4647a 100755 --- a/scripts/build-min +++ b/scripts/build-min @@ -1,6 +1,14 @@ #!/bin/bash set -e +if [ -z "$1" ]; then + echo "The version number must be passed to this script" + exit 1 +fi +VERSION=$1 + +echo "building binary $VERSION" + BUILD_IMAGE_NAME="go-dnsmasq-build" GOOS=${GOOS:-"darwin linux"} # GOARCH=${GOARCH:-"386 amd64 arm"} @@ -23,7 +31,7 @@ docker run --rm \ -os "$GOOS" \ -arch "$GOARCH" \ -output="go-dnsmasq-min_{{.OS}}-{{.Arch}}" \ - -ldflags="-w -s" \ + -ldflags "-w -s -X main.Version=$VERSION" \ -tags="netgo" \ -rebuild diff --git a/scripts/release b/scripts/release index 5152308..e31f4ab 100755 --- a/scripts/release +++ b/scripts/release @@ -1,15 +1,15 @@ #!/bin/bash set -e -if [ -z "$1" ]; then - echo "Pass the version number as the first arg. E.g.: scripts/release 1.2.3" - exit 1 -fi -VERSION=$1 + if [ -z "$GITHUB_TOKEN" ]; then echo "GITHUB_TOKEN must be set for github-release" exit 1 fi +VERSION=$(cat VERSION) + +echo "making release version $VERSION" + git checkout master git tag -f $VERSION @@ -22,8 +22,8 @@ git push -f --tags git checkout master -scripts/build -scripts/build-min +scripts/build $VERSION +scripts/build-min $VERSION # UPX compression echo "Packing binaries with UPX..."