Skip to content

Commit

Permalink
use GOBIN to skip the availability checks of Go tools in Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Jul 17, 2019
1 parent a4617b2 commit 3207e2e
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ VERSION := $$(make -s show-version)
VERSION_PATH := cli
CURRENT_REVISION := $(shell git rev-parse --short HEAD)
BUILD_LDFLAGS := "-X github.com/itchyny/$(BIN)/cli.revision=$(CURRENT_REVISION)"
GOBIN ?= $(shell go env GOPATH)/bin
export GO111MODULE=on

.PHONY: all
Expand All @@ -17,29 +18,29 @@ install:
go install -ldflags=$(BUILD_LDFLAGS) ./...

.PHONY: show-version
show-version:
@GO111MODULE=off go get github.com/motemen/gobump/cmd/gobump
show-version: $(GOBIN)/gobump
@gobump show -r $(VERSION_PATH)

$(GOBIN)/gobump:
@GO111MODULE=off go get github.com/motemen/gobump/cmd/gobump

.PHONY: cross
cross: crossdeps
cross: $(GOBIN)/goxz
goxz -n $(BIN) -pv=v$(VERSION) -include _$(BIN) -build-ldflags=$(BUILD_LDFLAGS) ./cmd/$(BIN)

.PHONY: crossdeps
crossdeps:
$(GOBIN)/goxz:
GO111MODULE=off go get github.com/Songmu/goxz/cmd/goxz

.PHONY: test
test: build
go test -v ./...

.PHONY: lint
lint: lintdeps
lint: $(GOBIN)/golint
go vet ./...
golint -set_exit_status ./...

.PHONY: lintdeps
lintdeps:
$(GOBIN)/golint:
GO111MODULE=off go get golang.org/x/lint/golint

.PHONY: clean
Expand All @@ -48,7 +49,7 @@ clean:
go clean

.PHONY: bump
bump:
bump: $(GOBIN)/gobump
@git status --porcelain | grep "^" && echo "git workspace is dirty" >/dev/stderr && exit 1 || :
gobump set $(shell sh -c 'read -p "input next version (current: $(VERSION)): " v && echo $$v') -w $(VERSION_PATH)
git commit -am "bump up version to $(VERSION)"
Expand All @@ -61,9 +62,11 @@ crossdocker:
docker run --rm -v `pwd`:"/$${PWD##*/}" -w "/$${PWD##*/}" golang make cross

.PHONY: upload
upload:
GO111MODULE=off go get github.com/tcnksm/ghr
upload: $(GOBIN)/ghr
ghr "v$(VERSION)" goxz

$(GOBIN)/ghr:
GO111MODULE=off go get github.com/tcnksm/ghr

.PHONY: release
release: test lint clean bump crossdocker upload

0 comments on commit 3207e2e

Please sign in to comment.