diff --git a/Makefile b/Makefile index c62c1a4..742be32 100644 --- a/Makefile +++ b/Makefile @@ -40,42 +40,55 @@ TAGS ?= LDFLAGS ?= -X 'main.Version=$(VERSION)' .PHONY: all -all: build +all: build ## Build the project (default target) .PHONY: test -test: +test: ## Run tests with coverage @$(GO) test -v -cover -coverprofile coverage.txt ./... && echo "\n==>\033[32m Ok\033[m\n" || exit 1 .PHONY: lint -lint: +lint: ## Run golangci-lint golangci-lint run -v .PHONY: fmt -fmt: +fmt: ## Format code with golangci-lint golangci-lint fmt .PHONY: install -install: $(GOFILES) +install: $(GOFILES) ## Install binary to GOPATH/bin $(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' . .PHONY: build -build: $(EXECUTABLE) +build: $(EXECUTABLE) ## Build binary to bin/ $(EXECUTABLE): $(GOFILES) $(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o bin/$@ . -build_linux_amd64: +.PHONY: build_linux_amd64 +build_linux_amd64: ## Build for Linux amd64 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/amd64/$(DEPLOY_IMAGE) . -build_linux_arm64: +.PHONY: build_linux_arm64 +build_linux_arm64: ## Build for Linux arm64 CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm64/$(DEPLOY_IMAGE) . -build_linux_arm: +.PHONY: build_linux_arm +build_linux_arm: ## Build for Linux arm (armv7) CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm/$(DEPLOY_IMAGE) . -clean: +.PHONY: clean +clean: ## Clean build artifacts $(GO) clean -x -i ./... rm -rf coverage.txt $(EXECUTABLE) $(DIST) -version: +.PHONY: help +help: ## Print this help message. + @echo "Usage: make [target]" + @echo "" + @echo "Targets:" + @echo "" + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: version +version: ## Print current version @echo $(VERSION)