Skip to content

Commit

Permalink
Add Makefile for release using ghr
Browse files Browse the repository at this point in the history
  • Loading branch information
gongo committed Mar 17, 2015
1 parent 8dad3fa commit 6fb8908
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
OWNER = gongo
REPOSITORY = 9t

COMMAND = 9t
MAIN_DIR = cmd/9t
VERSION = $(shell grep "const Version " $(MAIN_DIR)/version.go | sed -E 's/.*"(.+)"$$/\1/')

TOP = $(shell pwd)
BUILD_DIR = $(TOP)/pkg
DIST_DIR = $(TOP)/dist

XC_ARCH = "386 amd64"
XC_OS = "darwin linux windows"
XC_OUTPUT = "$(BUILD_DIR)/{{.OS}}_{{.Arch}}/{{.Dir}}"


setup:
gox -os $(XC_OS) -arch $(XC_ARCH) -build-toolchain
go get github.com/tcnksm/ghr

build:
rm -rf $(BUILD_DIR)
mkdir $(BUILD_DIR)
gox -os $(XC_OS) -arch $(XC_ARCH) -output $(XC_OUTPUT) ./$(MAIN_DIR)

dist: build
rm -rf $(DIST_DIR)
mkdir $(DIST_DIR)

@for dir in $$(find $(BUILD_DIR) -mindepth 1 -maxdepth 1 -type d); do \
platform=$$(basename $$dir) ; \
archive=$(COMMAND)_$(VERSION)_$$platform ;\
zip -j $(DIST_DIR)/$$archive.zip $$dir/* ;\
done

@pushd $(DIST_DIR) ; shasum -a 256 *.zip > ./SHA256SUMS ; popd

release:
ghr -u $(OWNER) -r $(REPOSITORY) $(VERSION) $(DIST_DIR)

clean:
rm -rf $(BUILD_DIR)
rm -rf $(DIST_DIR)

0 comments on commit 6fb8908

Please sign in to comment.