blocky/Makefile

45 lines
1.7 KiB
Makefile
Raw Normal View History

2021-01-17 21:48:13 +01:00
.PHONY: all clean build swagger test lint run buildMultiArchRelease help
2020-01-12 18:23:35 +01:00
.DEFAULT_GOAL := help
VERSION := $(shell git describe --always --tags)
BUILD_TIME=$(shell date '+%Y%m%d-%H%M%S')
DOCKER_IMAGE_NAME="spx01/blocky"
BINARY_NAME=blocky
BIN_OUT_DIR=bin
all: test lint build ## Build binary (with tests)
clean: ## cleans output directory
$(shell rm -rf $(BIN_OUT_DIR)/*)
swagger:
2021-01-17 21:48:13 +01:00
go get github.com/swaggo/swag/cmd/swag@v1.6.9
npm install bootprint bootprint-openapi html-inline
2020-04-08 23:03:07 +02:00
$(shell go env GOPATH)/bin/swag init -g api/api.go
$(shell) node_modules/bootprint/bin/bootprint.js openapi docs/swagger.json /tmp/swagger/
$(shell) node_modules/html-inline/bin/cmd.js /tmp/swagger/index.html > docs/swagger.html
build: ## Build binary
2020-04-08 23:03:07 +02:00
go build -v -ldflags="-w -s -X blocky/cmd.version=${VERSION} -X blocky/cmd.buildTime=${BUILD_TIME}" -o $(BIN_OUT_DIR)/$(BINARY_NAME)$(BINARY_SUFFIX)
2020-01-12 18:23:35 +01:00
test: ## run tests
2020-01-12 22:58:56 +01:00
go test -v -coverprofile=coverage.txt -covermode=atomic -cover ./...
2020-01-12 18:23:35 +01:00
2020-04-08 23:03:07 +02:00
lint: build ## run golangcli-lint checks
2020-01-12 18:23:35 +01:00
$(shell go env GOPATH)/bin/golangci-lint run
run: build ## Build and run binary
./$(BIN_OUT_DIR)/$(BINARY_NAME)
buildMultiArchRelease: ## builds binary for multiple archs
2020-05-24 22:42:43 +02:00
$(MAKE) build GOOS=linux GOARCH=arm GOARM=6 BINARY_SUFFIX=_${VERSION}_linux_arm32v6
$(MAKE) build GOOS=linux GOARCH=amd64 BINARY_SUFFIX=_${VERSION}_linux_amd64
2020-07-05 21:40:59 +02:00
$(MAKE) build GOOS=linux GOARCH=arm64 BINARY_SUFFIX=_${VERSION}_linux_arm64
2020-05-24 22:42:43 +02:00
$(MAKE) build GOOS=windows GOARCH=amd64 BINARY_SUFFIX=_${VERSION}_windows_amd64.exe
2020-01-12 18:23:35 +01:00
2020-02-13 17:18:24 +01:00
docker-build: ## Build docker image
docker build --tag ${DOCKER_IMAGE_NAME} .
2020-01-12 18:23:35 +01:00
help: ## Shows help
2020-02-12 21:38:08 +01:00
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'