diff --git a/Makefile b/Makefile index b871d19..a2b492b 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,29 @@ -# the current tag else the current git sha -VERSION := $(shell git tag --points-at=HEAD | grep . || git rev-parse --short HEAD) - -GOBUILD_ARGS := -ldflags "-X main.Version=$(VERSION)" -OS := $(shell go env GOOS) -ARCH := $(shell go env GOHOSTARCH) +VERSION=$(shell git describe --tags --candidates=1 --dirty) +FLAGS=-X main.Version=$(VERSION) -s -w # To create a new release: # $ git tag vx.x.x # $ git push --tags # $ make clean -# $ make release # this will create 2 binaries in ./bin - darwin and linux +# $ make release # this will create 3 binaries in ./bin # # Next, go to https://github.com/99designs/iamy/releases/new # - select the tag version you just created # - Attach the binaries from ./bin/* -release: bin/iamy-linux-amd64 bin/iamy-$(OS)-$(ARCH) +release: bin/iamy-linux-amd64 bin/iamy-darwin-amd64 bin/iamy-windows-386.exe bin/iamy-linux-amd64: @mkdir -p bin - docker run -it -v $$GOPATH:/go golang:latest go build $(GOBUILD_ARGS) -o /go/src/github.com/99designs/iamy/$@ github.com/99designs/iamy + GOOS=linux GOARCH=amd64 go build -o $@ -ldflags="$(FLAGS)" . + +bin/iamy-darwin-amd64: + @mkdir -p bin + GOOS=darwin GOARCH=amd64 go build -o $@ -ldflags="$(FLAGS)" . -bin/iamy-$(OS)-$(ARCH): +bin/iamy-windows-386.exe: @mkdir -p bin - go build $(GOBUILD_ARGS) -o bin/iamy-$(OS)-$(ARCH) . + GOOS=windows GOARCH=386 go build -o $@ -ldflags="$(FLAGS)" . clean: rm -f bin/*