From 8cde98016900365f5c8debf203366c6804b200e3 Mon Sep 17 00:00:00 2001 From: Jean Mertz Date: Mon, 24 Apr 2017 17:40:00 +0200 Subject: [PATCH] update Makefile --- Makefile | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 7d0f94d..4e4f527 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ BINARY=kubecrt -VERSION=0.1.0 +TAG=$(shell git for-each-ref refs/tags --sort=-taggerdate --format='%(refname:short)' --count=1) +MAJOR=`echo $(TAG) | awk -F[v.] '{print $$2}'` +MINOR=`echo $(TAG) | awk -F[v.] '{print $$3}'` +PATCH=`echo $(TAG) | awk -F[v.] '{print $$4}'` GIT_COMMIT=`git rev-parse --short @` LDFLAGS=-X github.com/blendle/kubecrt/config.version=$(VERSION) -X github.com/blendle/kubecrt/config.gitrev=$(GIT_COMMIT) @@ -8,7 +11,26 @@ build: mkdir -p bin go build -o bin/$(BINARY) -release: - mkdir -p _dist - GOOS=linux GOARCH=amd64 go build -ldflags "-s -w $(LDFLAGS)" -o _dist/$(BINARY) - GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w $(LDFLAGS)" -o _dist/$(BINARY)_darwin64 +release-prepare: + @mkdir -p _dist + +patch: release-prepare + @version=v$(MAJOR).$(MINOR).$$(expr $(PATCH) + 1); \ + git tag $$version; \ + GOOS=linux GOARCH=amd64 go build -ldflags "-s -w $(LDFLAGS)" -o _dist/$(BINARY)-$$version-linux-amd64; \ + GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w $(LDFLAGS)" -o _dist/$(BINARY)-$$version-darwin-amd64 + +minor: release-prepare + @version=v$(MAJOR).$$(expr $(MINOR) + 1).0; \ + git tag $$version; \ + GOOS=linux GOARCH=amd64 go build -ldflags "-s -w $(LDFLAGS)" -o _dist/$(BINARY)-$$version-linux-amd64; \ + GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w $(LDFLAGS)" -o _dist/$(BINARY)-$$version-darwin-amd64 + +major: release-prepare + @version=v$$(expr $(MAJOR) + 1).0.0; \ + git tag $$version; \ + GOOS=linux GOARCH=amd64 go build -ldflags "-s -w $(LDFLAGS)" -o _dist/$(BINARY)-$$version-linux-amd64; \ + GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w $(LDFLAGS)" -o _dist/$(BINARY)-$$version-darwin-amd64 + +push: + git push --tags