-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (40 loc) · 1.69 KB
/
Makefile
File metadata and controls
52 lines (40 loc) · 1.69 KB
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
# Build variables
BINARY_NAME=iperf3_exporter
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS=-s -w -X github.com/prometheus/common/version.Version=${VERSION} -X github.com/prometheus/common/version.Branch=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown") -X github.com/prometheus/common/version.Revision=${COMMIT} -X github.com/prometheus/common/version.BuildDate=${DATE} -X github.com/prometheus/common/version.BuildUser=makefile
REPO_NAME=$(shell grep -m 1 "^module" go.mod | awk '{print $$2}')
.PHONY: all default build clean test lint vet mod generate docker help
default: all
all: mod generate lint vet test build
help:
@echo "Available commands:"
@echo " all - Run mod, generate, lint, vet, tests and build the binary (default)"
@echo " build - Build the binary"
@echo " clean - Remove build artifacts"
@echo " test - Run tests"
@echo " lint - Run golangci-lint"
@echo " vet - Run go vet"
@echo " mod - Run go mod tidy and download"
@echo " generate - Run go generate"
@echo " docker - Build Docker image for local development"
build:
CGO_ENABLED=0 go build -ldflags "${LDFLAGS}" -o ${BINARY_NAME} ./cmd/iperf3_exporter
clean:
rm -f ${BINARY_NAME}
rm -rf dist/
test:
go test ./...
lint:
golangci-lint run
vet:
go vet ./...
mod:
go mod tidy
go mod download
generate:
go generate ./...
docker:
@echo "Building Docker image for local development..."
docker build -t ${REPO_NAME}:${VERSION} .