Skip to content

Commit

Permalink
update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMertz committed Apr 24, 2017
1 parent cdf3533 commit 8cde980
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
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)

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

0 comments on commit 8cde980

Please sign in to comment.