-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
30 lines (24 loc) · 1.17 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
help: ## Show help messages.
@grep -E '^[0-9a-zA-Z_-]+:(.*?## .*)?$$' $(MAKEFILE_LIST) | sed 's/^Makefile://' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
NAME:=tmancer
build_tag:=$(shell git describe --tags 2> /dev/null)
BUILDFLAGS:="-s -w -X github.com/lzambarda/$(NAME)/internal.Version=$(build_tag)"
.PHONY: dependencies
dependencies: ## Install test and build dependencies
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
.PHONY: lint
lint: ## Hmmm, lint?
go fmt ./...
golangci-lint run ./...
.PHONY: build
build: generate ## Build the binary for both linux and macos, you can use "build build_tag=CUSTOM"
@GOOS=darwin GOARCH=amd64 go build -ldflags $(BUILDFLAGS) -o ./bin/darwin/$(NAME) ./main.go
@GOOS=linux GOARCH=amd64 go build -ldflags $(BUILDFLAGS) -o bin/linux/$(NAME) ./main.go
.PHONY: build_assets
build_assets: build ## Build and pack binaries as assets for github, you can use "build_assets build_tag=CUSTOM"
@mkdir -p assets
@tar -zcvf assets/darwin-amd64-$(NAME).tgz ./bin/darwin/$(NAME)
@tar -zcvf assets/linux-amd64-$(NAME).tgz ./bin/linux/$(NAME)
.PHONY: generate
generate: ## Run stringer
go generate ./...