-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
53 lines (39 loc) · 2.06 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
.PHONY: build clean
PKG_LIST:=$(shell go list ./... | grep -v /vendor/)
EXECUTABLE:=lenses-cli
OUTPUT:=bin
LDFLAGS:= -ldflags "-s -w -X main.buildVersion=${VERSION} -X main.buildRevision=${REVISION} -X main.buildTime=$(shell date +%s)"
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
build: dep ## Build for development only
go build -o ./${OUTPUT}/${EXECUTABLE} ./cmd/${EXECUTABLE}
build-fast: ## Build for development only without verifying dependencies
go build -o ./${OUTPUT}/${EXECUTABLE} ./cmd/${EXECUTABLE}
build-linux: dep ## Build binary for linux
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build ${LDFLAGS} -o ${OUTPUT}/${EXECUTABLE}-linux-amd64 ./cmd/${EXECUTABLE}
build-docker: ## Builds Docker with linux lenses-cli
docker build -t lensesio/lenses-cli:${VERSION} .
dep: ## Ensure dependencies
go mod verify
clean: dep ## Clean
go clean
rm -r bin/
rm -f cover.out
cross-build: dep ## Build the app for multiple os/arch
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build ${LDFLAGS} -o ${OUTPUT}/${EXECUTABLE}-darwin-amd64 ./cmd/${EXECUTABLE}
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build ${LDFLAGS} -o ${OUTPUT}/${EXECUTABLE}-darwin-arm64 ./cmd/${EXECUTABLE}
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build ${LDFLAGS} -o ${OUTPUT}/${EXECUTABLE}-linux-amd64 ./cmd/${EXECUTABLE}
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build ${LDFLAGS} -o ${OUTPUT}/${EXECUTABLE}-linux-arm64 ./cmd/${EXECUTABLE}
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ${LDFLAGS} -o ${OUTPUT}/${EXECUTABLE}-windows-amd64.exe ./cmd/${EXECUTABLE}
format-check: ## Check format of source code according to Go's best practices
@goimports -l cmd/ pkg/ test/
publish: ## Publish lenses CLI as docker
bash -c "./publish-docker"
race: dep ## Run data race detector
go test -race -short ${PKG_LIST}
setup: ## Get all the necessary dependencies
go get -u golang.org/x/lint/golint
go get -u golang.org/x/tools/cmd/goimports
test: dep ## Run tests
go test -coverprofile=cover.out ./...
go tool cover -func=cover.out