Skip to content

Commit

Permalink
Makefile: release target
Browse files Browse the repository at this point in the history
`make release` builds whackanop for different target OS/arch's, packages
them up and places the resulting archives in a release folder.
  • Loading branch information
rgarcia committed Sep 2, 2014
1 parent 6f9d028 commit 6375b13
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,2 +1,4 @@
*~
c.out
build
release
34 changes: 29 additions & 5 deletions Makefile
@@ -1,9 +1,14 @@
VERSION := $(shell cat VERSION)
SHELL := /bin/bash
PKG = github.com/Clever/whackanop
SUBPKGS =
PKGS = $(PKG) $(SUBPKGS)

.PHONY: test $(PKGS)
PKG := github.com/Clever/whackanop
SUBPKGS :=
PKGS := $(PKG) $(SUBPKGS)
EXECUTABLE := whackanop
BUILDS := \
build/$(EXECUTABLE)-v$(VERSION)-darwin-amd64 \
build/$(EXECUTABLE)-v$(VERSION)-linux-amd64
COMPRESSED_BUILDS := $(BUILDS:%=%.tar.gz)
RELEASE_ARTIFACTS := $(COMPRESSED_BUILDS:build/%=release/%)

test: $(PKG)

Expand All @@ -15,3 +20,22 @@ $(PKG):
ifeq ($(HTMLCOV),1)
go tool cover -html=$(GOPATH)/src/$@/c.out
endif

build/$(EXECUTABLE)-v$(VERSION)-darwin-amd64:
GOARCH=amd64 GOOS=darwin go build -o "$@/$(EXECUTABLE)"
build/$(EXECUTABLE)-v$(VERSION)-linux-amd64:
GOARCH=amd64 GOOS=linux go build -o "$@/$(EXECUTABLE)"

%.tar.gz: %
tar -C `dirname $<` -zcvf "$<.tar.gz" `basename $<`

$(RELEASE_ARTIFACTS): release/% : build/%
mkdir -p release
cp $< $@

release: $(RELEASE_ARTIFACTS)

clean:
rm -rf build release

.PHONY: test $(PKGS) clean github-release
1 change: 1 addition & 0 deletions VERSION
@@ -0,0 +1 @@
0.1.0

0 comments on commit 6375b13

Please sign in to comment.