From 2e4a1eeed530b0840afdfd565b0c7a9a97fc6efb Mon Sep 17 00:00:00 2001 From: Carlo Strub Date: Wed, 19 Apr 2017 13:36:52 +0000 Subject: [PATCH] Borrow Makefile from github.com/Masterminds/glide --- Makefile | 64 ++++++++++++++++++++++++++++++++++++ cmd/{main.go => sisyphus.go} | 4 ++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 Makefile rename cmd/{main.go => sisyphus.go} (99%) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5877fa9 --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +SISYPHUS_GO_EXECUTABLE ?= go +DIST_DIRS := find * -type d -exec +VERSION ?= $(shell git describe --tags) +VERSION_INCODE = $(shell perl -ne '/^var version.*"([^"]+)".*$$/ && print "v$$1\n"' sisyphus.go) +VERSION_INCHANGELOG = $(shell perl -ne '/^\# Release (\d+(\.\d+)+) / && print "$$1\n"' CHANGELOG.md | head -n1) + +build: + ${SISYPHUS_GO_EXECUTABLE} build -o sisyphus -ldflags "-X main.version=${VERSION}" cmd/sisyphus.go + +install: build + install -d ${DESTDIR}/usr/local/bin/ + install -m 755 ./sisyphus ${DESTDIR}/usr/local/bin/sisyphus + +test: + ${SISYPHUS_GO_EXECUTABLE} test . + +integration-test: + ${SISYPHUS_GO_EXECUTABLE} build + ./sisyphus run + ./sisyphus start + ./sisyphus restart + ./sisyphus status + ./sisyphus stop + +clean: + rm -f ./sisyphus.test + rm -f ./sisyphus + rm -rf ./dist + +bootstrap-dist: + ${SISYPHUS_GO_EXECUTABLE} get -u github.com/franciscocpg/gox + cd ${GOPATH}/src/github.com/franciscocpg/gox && git checkout dc50315fc7992f4fa34a4ee4bb3d60052eeb038e + cd ${GOPATH}/src/github.com/franciscocpg/gox && ${SISYPHUS_GO_EXECUTABLE} install + +build-all: + gox -verbose \ + -ldflags "-X main.version=${VERSION}" \ + -os="linux darwin windows freebsd openbsd netbsd" \ + -arch="amd64 386 armv5 armv6 armv7 arm64" \ + -osarch="!darwin/arm64" \ + -output="dist/{{.OS}}-{{.Arch}}/{{.Dir}}" . + +dist: build-all + cd dist && \ + $(DIST_DIRS) cp ../LICENSE {} \; && \ + $(DIST_DIRS) cp ../README.md {} \; && \ + $(DIST_DIRS) tar -zcf sisyphus-${VERSION}-{}.tar.gz {} \; && \ + $(DIST_DIRS) zip -r sisyphus-${VERSION}-{}.zip {} \; && \ + cd .. + +verify-version: + @if [ "$(VERSION_INCODE)" = "v$(VERSION_INCHANGELOG)" ]; then \ + echo "sisyphus: $(VERSION_INCHANGELOG)"; \ + elif [ "$(VERSION_INCODE)" = "v$(VERSION_INCHANGELOG)-dev" ]; then \ + echo "sisyphus (development): $(VERSION_INCHANGELOG)"; \ + else \ + echo "Version number in sisyphus.go does not match CHANGELOG.md"; \ + echo "sisyphus.go: $(VERSION_INCODE)"; \ + echo "CHANGELOG : $(VERSION_INCHANGELOG)"; \ + exit 1; \ + fi + +.PHONY: build test install clean bootstrap-dist build-all dist integration-test verify-version + diff --git a/cmd/main.go b/cmd/sisyphus.go similarity index 99% rename from cmd/main.go rename to cmd/sisyphus.go index 68bbfaa..14b2859 100644 --- a/cmd/main.go +++ b/cmd/sisyphus.go @@ -14,6 +14,8 @@ import ( "github.com/urfave/cli" ) +var version = "0.1.0" + func main() { // Define App @@ -27,7 +29,7 @@ func main() { operate directly on the Maildir of a user in a fully transparent mode, without any need for configuration or active operation.` app.HelpName = "Intelligent Junk and Spam Mail Handler" - app.Version = "0.0.0" + app.Version = version app.Copyright = "(c) 2017, Carlo Strub. All rights reserved. This binary is licensed under a BSD 3-Clause License." app.Authors = []cli.Author{ {