-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (59 loc) · 1.35 KB
/
Copy pathMakefile
File metadata and controls
74 lines (59 loc) · 1.35 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
BINARY := commitkit
BUILD_DIR := dist
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -s -w \
-X main.version=$(VERSION) \
-X main.commit=$(COMMIT) \
-X main.buildDate=$(BUILD_DATE)
.PHONY: setup build install test lint clean release
setup:
go mod tidy
$(MAKE) build
$(MAKE) install
commitkit install-hook
build:
go build \
-trimpath \
-ldflags "$(LDFLAGS)" \
-o $(BINARY) \
./
install:
go install \
-trimpath \
-ldflags "$(LDFLAGS)" \
./
test:
go test ./...
lint:
go vet ./...
release:
@mkdir -p $(BUILD_DIR)
GOOS=darwin GOARCH=arm64 go build \
-trimpath \
-ldflags "$(LDFLAGS)" \
-o $(BUILD_DIR)/$(BINARY)-darwin-arm64 \
./
GOOS=darwin GOARCH=amd64 go build \
-trimpath \
-ldflags "$(LDFLAGS)" \
-o $(BUILD_DIR)/$(BINARY)-darwin-amd64 \
./
GOOS=linux GOARCH=amd64 go build \
-trimpath \
-ldflags "$(LDFLAGS)" \
-o $(BUILD_DIR)/$(BINARY)-linux-amd64 \
./
GOOS=linux GOARCH=arm64 go build \
-trimpath \
-ldflags "$(LDFLAGS)" \
-o $(BUILD_DIR)/$(BINARY)-linux-arm64 \
./
GOOS=windows GOARCH=amd64 go build \
-trimpath \
-ldflags "$(LDFLAGS)" \
-o $(BUILD_DIR)/$(BINARY)-windows-amd64.exe \
./
clean:
rm -rf $(BINARY) $(BUILD_DIR)