-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (56 loc) · 1.69 KB
/
Makefile
File metadata and controls
73 lines (56 loc) · 1.69 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
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*")
GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
TARGETOS ?= linux
TARGETARCH ?= amd64
VERSION ?= next
VERSION_NUMBER ?= 0.0.0
ifneq ($(CI_COMMIT_TAG),)
VERSION := $(CI_COMMIT_TAG:v%=%)
VERSION_NUMBER := ${VERSION}
endif
# append commit-sha to next version
BUILD_VERSION := $(VERSION)
ifeq ($(BUILD_VERSION),next)
CI_COMMIT_SHA ?= $(shell git rev-parse HEAD)
BUILD_VERSION := $(shell echo "next-$(shell echo ${CI_COMMIT_SHA} | head -c 8)")
endif
LDFLAGS := -s -w -extldflags "-static" -X main.version=${BUILD_VERSION}
.PHONY: all
all: build
vendor:
go mod tidy
go mod vendor
format: install-gofumpt ## Format source code
@gofumpt -extra -w ${GOFILES_NOVENDOR}
formatcheck:
@([ -z "$(shell gofumpt -d $(GOFILES_NOVENDOR) | head)" ]) || (echo "Source is unformatted"; exit 1)
install-golangci:
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest ; \
fi ;
install-gofumpt:
@hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
go install mvdan.cc/gofumpt@latest; \
fi ; \
.PHONY: install-tools
install-tools: install-golangci install-gofumpt ## Install development tools
.PHONY: clean
clean:
go clean -i ./...
rm -rf release/
.PHONY: lint
lint: install-golangci ## Lint code
@echo "Running golangci-lint"
golangci-lint run
.PHONY: vet
vet:
@echo "Running go vet..."
@go vet $(GO_PACKAGES)
.PHONY: test
test:
go test -race -cover ./...
build:
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags '${LDFLAGS}' -o release/plugin-codecov
.PHONY: version
version:
@echo ${VERSION}