-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
59 lines (46 loc) · 1.21 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
.PHONY: all clean build install uninstall check lint fmt vendor test
PACKAGE_NAME := lazyhis
BUILD_DIR := build
DST_DIR ?= $(HOME)/.local/bin
VERSION := $(shell git describe --tags --dirty)
COMMIT := $(shell git rev-parse --short HEAD)
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
all: install
## CODE QUALITY & TESTS
check: vendor fmt lint test
vendor:
@echo "Vendor dependencies..."
go mod tidy
go mod vendor
fmt:
@echo "Formatting code..."
gofmt -w .
golines -w . --max-len=88
lint:
@echo "Running linters..."
golangci-lint run
test:
@echo "Running tests..."
go test -v ./...
## BUILD & INSTALLATION
info:
@echo "Version: $(VERSION)"
@echo "Commit: $(COMMIT)"
@echo "Data: $(DATE)"
build: info
@echo "Building $(PACKAGE_NAME)..."
@mkdir -p $(BUILD_DIR)
go build \
-ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)" \
-o $(BUILD_DIR)/lazyhis main.go
install: build
@echo "Installing $(PACKAGE_NAME)..."
@mkdir -p $(DST_DIR)
ln -sf $(PWD)/$(BUILD_DIR)/$(PACKAGE_NAME) $(DST_DIR)
## CLEAN
uninstall:
@echo "Uninstalling $(PACKAGE_NAME)..."
rm -f $(DST_DIR)/$(PACKAGE_NAME)
clean: uninstall
@echo "Cleaning $(BUILD_DIR) directory..."
rm -rf $(BUILD_DIR)