-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
47 lines (33 loc) · 997 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
37
38
39
40
41
42
43
44
45
46
47
APP_NAME := ssh-aliases
APP_VERSION := $(shell cat VERSION)
PACKAGES := $(shell go list ./... | grep -v /vendor/)
BUILD_FOLDER := target
DIST_FOLDER := dist
GIT_DESC := $(shell git describe)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
SRC := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
.PHONY: all version fmt clean test build release lint lint-deps
ifneq "$(APP_VERSION)" "$(GIT_DESC)"
APP_VERSION := $(GIT_DESC)-$(GIT_BRANCH)
endif
all: clean build
version:
@echo $(APP_VERSION)
clean:
@go clean -v .
@rm -rf $(BUILD_FOLDER)
@rm -rf $(DIST_FOLDER)
test:
@go test -cover ./...
build:
@go build -o $(BUILD_FOLDER)/$(APP_NAME) \
-ldflags '-s -w -X main.Version=$(APP_VERSION)'
release: clean lint build
@bash ./package.sh $(APP_VERSION)
fmt: lint-deps
@goimports -w $(SRC)
@gofmt -l -s -w $(SRC)
lint: lint-deps
@golangci-lint run
lint-deps:
@which golangci-lint > /dev/null || go get -u github.com/golangci/golangci-lint/cmd/golangci-lint