forked from newrelic/sidecar
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
45 lines (34 loc) · 963 Bytes
/
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
APP_NAME = sidecar
APP_VSN ?= $(shell git rev-parse --short HEAD)
.PHONY: help
help: #: Show this help message
@echo "$(APP_NAME):$(APP_VSN)"
@awk '/^[A-Za-z_ -]*:.*#:/ {printf("%c[1;32m%-15s%c[0m", 27, $$1, 27); for(i=3; i<=NF; i++) { printf("%s ", $$i); } printf("\n"); }' Makefile* | sort
CGO_ENABLED ?= 0
GO = GO_ENABLED=$(CGO_ENABLED) go
GO_BUILD_FLAGS = -ldflags "-X main.Version=${APP_VSN}"
### Dev
.PHONY: run
run: #: Run the application
$(GO) run $(GO_BUILD_FLAGS) `ls -1 *.go | grep -v _test.go`
.PHONY: code-check
code-check:
golangci-lint run
### Build
.PHONY: build
build: #: Build the app locally
build: clean
GOOS=linux $(GO) build $(GO_BUILD_FLAGS) -o $(APP_NAME)
./docker/build.sh
.PHONY: release
release: #: Build and upload the release to GitHub
goreleaser
.PHONY: clean
clean: #: Clean up build artifacts
clean:
$(RM) ./$(APP_NAME)
### Test
.PHONY: test
test: #: Run Go unit tests
test:
GO111MODULE=on $(GO) test -v ./...