-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (35 loc) · 1.46 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
SHELL := /bin/bash
BINARY_NAME ?= gips
CONTAINER_NAME ?= us-west1-docker.pkg.dev/dl-shared-artifacts/sre/gips
BUILD_COMMAND=-mod=vendor -o bin/$(BINARY_NAME) ../$(BINARY_NAME)
UNAME=$(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(shell uname -m)
GIT_SHA=$(shell git rev-parse HEAD)
all: build
deps: ## Install all dependencies.
go mod vendor
go mod tidy -compat=1.21
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
clean: ## Remove compiled binaries.
rm -f bin/$(BINARY_NAME) || true
rm -f bin/$(BINARY_NAME)*gz || true
docker: ## Build Docker image
docker buildx build . --platform linux/amd64,linux/arm64 -t $(CONTAINER_NAME):$(GIT_SHA) --push
build: clean
go build $(BUILD_COMMAND)
rebuild: clean ## Force rebuild of all packages.
go build -a $(BUILD_COMMAND)
linux: clean ## Compile for Linux/Docker.
CGO_ENABLED=0 GOOS=linux go build $(BUILD_COMMAND)
gzip: ## Compress current compiled binary.
gzip bin/$(BINARY_NAME)
mv bin/$(BINARY_NAME).gz bin/$(BINARY_NAME)-$(UNAME)-$(ARCH).gz
release: build gzip ## Full release process.
unit: ## Run unit tests.
go test -mod=vendor -cover -race -short ./... -v
lint: ## See https://github.com/golangci/golangci-lint#install for install instructions
golangci-lint run ./...
config:
kubectl create configmap $(BINARY_NAME)-config --from-file=config.yaml
.PHONY: help all deps clean build gzip release unit lint docker config