-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
36 lines (28 loc) · 974 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
VERSION := $(shell git describe --tags --abbrev=0)
REVISION := $(shell git rev-parse --short HEAD)
LDFLAGS := -X 'main.Version=$(VERSION)' \
-X 'main.Revision=$(REVISION)'
GOIMPORTS ?= goimports
GOCILINT ?= golangci-lint
GORELEASER ?= goreleaser
GO ?= GO111MODULE=on go
.DEFAULT_GOAL := help
.PHONY: fmt
fmt: ## Formatting source codes.
@$(GOIMPORTS) -w .
.PHONY: lint
lint: ## Run golint and go vet.
@$(GOCILINT) run --no-config --disable-all --enable=goimports --enable=misspell ./...
.PHONY: test
test: ## Run the tests.
@$(GO) test ./...
.PHONY: build
build: ## Build a binary.
$(GO) build -o gh-prompt -ldflags "$(LDFLAGS)" ./cmd/gh-prompt/main.go
.PHONY: cross
cross: ## Cross build using goreleaser.
$(GORELEASER) --snapshot --skip-publish --rm-dist
.PHONY: help
help: ## Show help text
@echo "Commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'