This repository was archived by the owner on Jun 4, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (44 loc) · 1.18 KB
/
Makefile
File metadata and controls
57 lines (44 loc) · 1.18 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
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
ifneq ($(CI_COMMIT_TAG),)
VERSION := $(CI_COMMIT_TAG:v%=%)
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
.PHONY: vendor
vendor:
go mod tidy
go mod vendor
.PHONY: formatcheck
formatcheck:
@([ -z "$(shell gofmt -d $(GOFILES_NOVENDOR) | head)" ]) || (echo "Source is unformatted"; exit 1)
.PHONY: format
format:
@gofmt -w ${GOFILES_NOVENDOR}
.PHONY: clean
clean:
go clean -i ./...
rm -rf release/
.PHONY: vet
vet:
@echo "Running go vet..."
@go vet $(GO_PACKAGES)
.PHONY: test
test:
go test -race -cover ./...
.PHONY: build
build:
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags '${LDFLAGS}' -o release/plugin-github-release
.PHONY: version
version:
@echo ${BUILD_VERSION}