From d6245ab24065917ac16be2ff10ddd3934f41fe54 Mon Sep 17 00:00:00 2001 From: Camilo Aguilar Date: Tue, 17 Nov 2015 02:05:54 -0500 Subject: [PATCH] Adds additional release tooling --- Makefile | 10 ++++++++++ common.mk | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 Makefile create mode 100644 common.mk diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8ab1e3c --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +GHACCOUNT := hooklift +NAME := iso9660 +VERSION := v1.0.0 + +include common.mk + +deps: + go get github.com/c4milo/github-release + go get github.com/mitchellh/gox + go get github.com/docopt/docopt-go diff --git a/common.mk b/common.mk new file mode 100644 index 0000000..035a224 --- /dev/null +++ b/common.mk @@ -0,0 +1,43 @@ +PLATFORM := $(shell go env | grep GOHOSTOS | cut -d '"' -f 2) +ARCH := $(shell go env | grep GOARCH | cut -d '"' -f 2) +BRANCH := $(shell git rev-parse --abbrev-ref HEAD) +LDFLAGS := -ldflags "-X main.Version=$(VERSION) -X main.Name=$(NAME)" + +test: + go test ./... + +build: + go build -o build/$(NAME) $(LDFLAGS) cmd/$(NAME)/main.go + +install: + go install $(LDFLAGS) + +compile: + @rm -rf build/ + @gox $(LDFLAGS) \ + -os="darwin" \ + -os="linux" \ + -os="solaris" \ + -os="freebsd" \ + -os="windows" \ + -output "build/$(NAME)_$(VERSION)_{{.OS}}_{{.Arch}}/$(NAME)" \ + ./... + +dist: compile + $(eval FILES := $(shell ls build)) + @rm -rf dist && mkdir dist + @for f in $(FILES); do \ + (cd $(shell pwd)/build/$$f && tar -cvzf ../../dist/$$f.tar.gz *); \ + (cd $(shell pwd)/dist && shasum -a 512 $$f.tar.gz > $$f.sha512); \ + echo $$f; \ + done + +release: dist + @latest_tag=$$(git describe --tags `git rev-list --tags --max-count=1`); \ + comparison="$$latest_tag..HEAD"; \ + if [ -z "$$latest_tag" ]; then comparison=""; fi; \ + changelog=$$(git log $$comparison --oneline --no-merges --reverse); \ + github-release $(GHACCOUNT)/$(NAME) $(VERSION) $(BRANCH) "**Changelog**
$$changelog" 'dist/*'; \ + git pull + +.PHONY: test build install compile deps dist release