From 594a50d48cb5b802a226376855109c72e1b721b2 Mon Sep 17 00:00:00 2001 From: Joshua Deare Date: Thu, 8 Sep 2016 14:42:29 -0700 Subject: [PATCH] add package versions to makefile --- Makefile | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4729e602..0ab256b4 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,29 @@ PKG := github.com/compose/governor PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/) GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/) VERSION := $(shell git describe --tags) +RELEASES := windows|amd64 linux|amd64 linux|arm -release: vet lint test build +release: vet lint test build package-releases -build: +package-releases: + $(foreach release,$(RELEASES), \ + $(call release-version,$(firstword $(subst |, ,$(release))),\ + $(lastword $(subst |, ,$(release))))\ + ) + +define release-version + @echo "Building release for $(strip $(1)):$(strip $(2))" + mkdir -p ./build + GOOS=$(strip $(1)) GOARCH=$(strip $(2)) go build -v -o ./build/${OUT} -ldflags "-X main.version=${VERSION}" ${PKG} + tar -C ./build -cvzf ./build/governor-${VERSION}-$(strip $(1))-$(strip $(2)).tar.gz ${OUT} + rm ./build/${OUT} + +endef + + +build: build-native + +build-native: go build -v -o ${OUT} -ldflags "-X main.version=${VERSION}" ${PKG} vet: