diff --git a/.gitignore b/.gitignore index 00d1745..ec40cc4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ vendor config.json *.bolt -dist \ No newline at end of file +dist +build \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d8e1496 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +SHELL = bash +GOTOOLS = \ + github.com/mjibson/esc \ + github.com/mitchellh/gox \ + +GOOS=$(shell go env GOOS) +GOARCH=$(shell go env GOARCH) + +# Get the git commit +GIT_LATEST_TAG=$(shell git describe --abbrev=0 --tags) +VERSION_IMPORT=github.com/andrexus/cloud-initer/cmd +GOLDFLAGS=-X $(VERSION_IMPORT).Version=$(GIT_LATEST_TAG) + +export GOLDFLAGS + +# all builds binaries for all targets +all: bin + +bin: tools + go generate + @echo "==> Building..." + gox -ldflags "${GOLDFLAGS}" -osarch "darwin/amd64 linux/386 linux/amd64 linux/arm" -output "build/{{.OS}}_{{.Arch}}_{{.Dir}}" + +tools: + go get -u -v $(GOTOOLS) + +.PHONY: all bin tools \ No newline at end of file diff --git a/cmd/version.go b/cmd/version.go index 9599c6e..2c84070 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -var Version string = "0.1.1" +var Version string = "unset" var versionCmd = cobra.Command{ Run: showVersion,