-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
164 lines (124 loc) · 4.35 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
SHELL := bash
NAME := semver-bump-action
IMPORT := github.com/cbrgm/semver-bump-action
BIN := bin
DIST := dist
ifeq ($(OS), Windows_NT)
EXECUTABLE := $(NAME).exe
UNAME := Windows
else
EXECUTABLE := $(NAME)
UNAME := $(shell uname -s)
endif
GOBUILD ?= CGO_ENABLED=0 go build
PACKAGES ?= $(shell go list ./...)
SOURCES ?= $(shell find . -name "*.go" -type f)
GENERATE ?= $(PACKAGES)
TAGS ?=
ifndef OUTPUT
ifeq ($(GITHUB_REF_TYPE), tag)
OUTPUT ?= $(subst v,,$(GITHUB_REF_NAME))
else
OUTPUT ?= testing
endif
endif
ifndef VERSION
ifeq ($(GITHUB_REF_TYPE), tag)
VERSION ?= $(subst v,,$(GITHUB_REF_NAME))
else
VERSION ?= $(shell git describe --tags --abbrev=0)-dirty
endif
endif
ifndef DATE
DATE := $(shell date -u '+%Y%m%d')
endif
ifndef SHA
SHA := $(shell git rev-parse --short HEAD)
endif
LDFLAGS += -s -w -extldflags "-static" -X "main.Version=$(VERSION)" -X "main.Revision=$(SHA)" -X "main.BuildDate=$(DATE)"
GCFLAGS += all=-N -l
.PHONY: all
all: build
.PHONY: sync
sync:
go mod download
.PHONY: clean
clean:
go clean -i ./...
rm -rf $(BIN) $(DIST)
.PHONY: fmt
fmt:
gofmt -s -w $(SOURCES)
.PHONY: vet
vet:
go vet $(PACKAGES)
.PHONY: lint
lint:
golangci-lint run --out-format=colored-line-number --timeout 5m
.PHONY: generate
generate:
go generate $(GENERATE)
.PHONY: test
test:
go test -coverprofile coverage.out $(PACKAGES)
.PHONY: install
install: $(SOURCES)
go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME)
.PHONY: build
build: $(BIN)/$(EXECUTABLE)
$(BIN)/$(EXECUTABLE): $(SOURCES)
$(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
$(BIN)/$(EXECUTABLE)-debug: $(SOURCES)
$(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME)
.PHONY: release
release: $(DIST) release-linux release-darwin release-windows
$(DIST):
mkdir -p $(DIST)
.PHONY: release-linux
release-linux: $(DIST) \
$(DIST)/$(EXECUTABLE)_linux-386 \
$(DIST)/$(EXECUTABLE)_linux-amd64 \
$(DIST)/$(EXECUTABLE)_linux-arm-5 \
$(DIST)/$(EXECUTABLE)_linux-arm-6 \
$(DIST)/$(EXECUTABLE)_linux-arm-7 \
$(DIST)/$(EXECUTABLE)_linux-arm64 \
$(DIST)/$(EXECUTABLE)_linux-mips \
$(DIST)/$(EXECUTABLE)_linux-mips64 \
$(DIST)/$(EXECUTABLE)_linux-mipsle \
$(DIST)/$(EXECUTABLE)_linux-mips64le
$(DIST)/$(EXECUTABLE)_linux-386:
GOOS=linux GOARCH=386 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
$(DIST)/$(EXECUTABLE)_linux-amd64:
GOOS=linux GOARCH=amd64 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
$(DIST)/$(EXECUTABLE)_linux-arm-5:
GOOS=linux GOARCH=arm GOARM=5 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
$(DIST)/$(EXECUTABLE)_linux-arm-6:
GOOS=linux GOARCH=arm GOARM=6 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
$(DIST)/$(EXECUTABLE)_linux-arm-7:
GOOS=linux GOARCH=arm GOARM=7 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
$(DIST)/$(EXECUTABLE)_linux-arm64:
GOOS=linux GOARCH=arm64 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
$(DIST)/$(EXECUTABLE)_linux-mips:
GOOS=linux GOARCH=mips $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
$(DIST)/$(EXECUTABLE)_linux-mips64:
GOOS=linux GOARCH=mips64 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
$(DIST)/$(EXECUTABLE)_linux-mipsle:
GOOS=linux GOARCH=mipsle $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
$(DIST)/$(EXECUTABLE)_linux-mips64le:
GOOS=linux GOARCH=mips64le $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
.PHONY: release-darwin
release-darwin: $(DIST) \
$(DIST)/$(EXECUTABLE)_darwin-amd64 \
$(DIST)/$(EXECUTABLE)_darwin-arm64
$(DIST)/$(EXECUTABLE)_darwin-amd64:
GOOS=darwin GOARCH=amd64 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
$(DIST)/$(EXECUTABLE)_darwin-arm64:
GOOS=darwin GOARCH=arm64 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
.PHONY: release-windows
release-windows: $(DIST) \
$(DIST)/$(EXECUTABLE)_windows-4.0-386.exe \
$(DIST)/$(EXECUTABLE)_windows-4.0-amd64.exe
$(DIST)/$(EXECUTABLE)_windows-4.0-386.exe:
GOOS=windows GOARCH=386 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)
$(DIST)/$(EXECUTABLE)_windows-4.0-amd64.exe:
GOOS=windows GOARCH=amd64 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)