From de6ddf7e1b514c4cbf81e3a58138810a5abe9941 Mon Sep 17 00:00:00 2001 From: teru Date: Fri, 16 Mar 2018 11:06:04 +0900 Subject: [PATCH 1/3] Simplify PHONY targets --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1e04c4f..f428b3b 100644 --- a/Makefile +++ b/Makefile @@ -9,10 +9,11 @@ DIR_RELEASE=release VERSION=$(patsubst "%",%,$(lastword $(shell grep 'const Version' version.go))) GITTAG=$(shell git rev-parse --short HEAD) -.PHONY: build build-linux-amd64 build-linux-386 clean - default: build +FORCE: +.PHONY: FORCE + $(DIR_BUILD)/bin/$(THIS_GOOS)_$(THIS_GOARCH)/dep: mkdir -p /tmp/go GOPATH=/tmp/go go get -d -v github.com/golang/dep @@ -24,7 +25,7 @@ dep: $(DIR_BUILD)/bin/$(THIS_GOOS)_$(THIS_GOARCH)/dep installdeps: dep $(DIR_BUILD)/bin/$(THIS_GOOS)_$(THIS_GOARCH)/dep ensure -v -vendor-only -build: +build: FORCE go build -v -i -ldflags "-X main.gittag=$(GITTAG)" -o $(DIR_BUILD)/mailfull_$(GOOS)_$(GOARCH)/mailfull cmd/mailfull/*.go .build-docker: From 8ecd1f0f79de9a68a56fe203fa2154c2a90ad051 Mon Sep 17 00:00:00 2001 From: teru Date: Fri, 16 Mar 2018 11:07:40 +0900 Subject: [PATCH 2/3] Update go to 1.10 --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f428b3b..b7bf60d 100644 --- a/Makefile +++ b/Makefile @@ -26,12 +26,12 @@ installdeps: dep $(DIR_BUILD)/bin/$(THIS_GOOS)_$(THIS_GOARCH)/dep ensure -v -vendor-only build: FORCE - go build -v -i -ldflags "-X main.gittag=$(GITTAG)" -o $(DIR_BUILD)/mailfull_$(GOOS)_$(GOARCH)/mailfull cmd/mailfull/*.go + go build -v -ldflags "-X main.gittag=$(GITTAG)" -o $(DIR_BUILD)/mailfull_$(GOOS)_$(GOARCH)/mailfull cmd/mailfull/*.go .build-docker: docker run --rm -v $(DIR_PKG):/go/pkg -v $(PWD):/go/src/github.com/directorz/mailfull-go -w /go/src/github.com/directorz/mailfull-go \ - -e GOOS=$(GOOS) -e GOARCH=$(GOARCH) golang:1.9.2 \ - go build -v -i -ldflags "-X main.gittag=$(GITTAG)" -o $(DIR_BUILD)/mailfull_$(GOOS)_$(GOARCH)/mailfull cmd/mailfull/*.go + -e GOOS=$(GOOS) -e GOARCH=$(GOARCH) golang:1.10 \ + go build -v -ldflags "-X main.gittag=$(GITTAG)" -o $(DIR_BUILD)/mailfull_$(GOOS)_$(GOARCH)/mailfull cmd/mailfull/*.go build-linux-amd64: @$(MAKE) .build-docker GOOS=linux GOARCH=amd64 From e7254c6df62df3e989bdba33ba0638a2faa006b1 Mon Sep 17 00:00:00 2001 From: teru Date: Fri, 16 Mar 2018 11:27:48 +0900 Subject: [PATCH 3/3] Use internal `ghr` command --- Makefile | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b7bf60d..1f08e11 100644 --- a/Makefile +++ b/Makefile @@ -22,9 +22,18 @@ $(DIR_BUILD)/bin/$(THIS_GOOS)_$(THIS_GOARCH)/dep: dep: $(DIR_BUILD)/bin/$(THIS_GOOS)_$(THIS_GOARCH)/dep +$(DIR_BUILD)/bin/$(THIS_GOOS)_$(THIS_GOARCH)/ghr: + mkdir -p /tmp/go + GOPATH=/tmp/go go get -d -v github.com/tcnksm/ghr + GOPATH=/tmp/go go build -v -o $(DIR_BUILD)/bin/$(THIS_GOOS)_$(THIS_GOARCH)/ghr github.com/tcnksm/ghr + rm -rf /tmp/go + +ghr: $(DIR_BUILD)/bin/$(THIS_GOOS)_$(THIS_GOARCH)/ghr + installdeps: dep $(DIR_BUILD)/bin/$(THIS_GOOS)_$(THIS_GOARCH)/dep ensure -v -vendor-only + build: FORCE go build -v -ldflags "-X main.gittag=$(GITTAG)" -o $(DIR_BUILD)/mailfull_$(GOOS)_$(GOARCH)/mailfull cmd/mailfull/*.go @@ -39,6 +48,7 @@ build-linux-amd64: build-linux-386: @$(MAKE) .build-docker GOOS=linux GOARCH=386 + release: release-linux-amd64 release-linux-386 release-linux-amd64: build-linux-amd64 @@ -56,12 +66,13 @@ release-targz: dir-$(DIR_RELEASE) dir-$(DIR_RELEASE): mkdir -p $(DIR_RELEASE) -release-upload: release-linux-amd64 release-linux-386 release-github-token - ghr -u directorz -r mailfull-go -t $(shell cat github_token) --replace --draft $(VERSION) $(DIR_RELEASE) +release-upload: ghr release-linux-amd64 release-linux-386 release-github-token + $(DIR_BUILD)/bin/$(THIS_GOOS)_$(THIS_GOARCH)/ghr -u directorz -r mailfull-go -t $(shell cat github_token) --replace --draft $(VERSION) $(DIR_RELEASE) release-github-token: github_token @echo "file \"github_token\" is required" + clean: -rm -rf $(DIR_BUILD) -rm -rf $(DIR_RELEASE)