-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (72 loc) · 2.48 KB
/
Copy pathMakefile
File metadata and controls
89 lines (72 loc) · 2.48 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
.PHONY: all build clean test test-integration vuln lint tidy version release-check
GOOS_ARCH := linux/amd64 linux/arm64 linux/386 linux/arm darwin/amd64 darwin/arm64 windows/amd64 windows/arm64 windows/386
DIST_DIR := dist
# Version information - can be overridden by environment variable
ifeq ($(origin VERSION), environment)
# VERSION is set from environment
else
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
endif
BUILD_TIME := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
# Build flags
LDFLAGS := -ldflags="-s -w -X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME) -X main.GitCommit=$(GIT_COMMIT)"
all: build
build:
@echo "Building pipekit..."
@echo "Version: $(VERSION)"
@echo "Build time: $(BUILD_TIME)"
@echo "Git commit: $(GIT_COMMIT)"
@mkdir -p $(DIST_DIR)
CGO_ENABLED=0 go build $(LDFLAGS) -o $(DIST_DIR)/pipekit .
@echo "Build complete: $(DIST_DIR)/pipekit"
build-all:
@echo "Building binaries for all platforms..."
@mkdir -p $(DIST_DIR)
@for t in $(GOOS_ARCH); do \
os=$${t%/*}; arch=$${t#*/}; \
bin_name=pipekit-$${os}-$${arch}; \
if [ "$$os" = "windows" ]; then bin_name="$${bin_name}.exe"; fi; \
bin_path=$(DIST_DIR)/$$bin_name; \
echo " Building for $$os/$$arch..."; \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build $(LDFLAGS) -o $$bin_path .; \
done
@echo "Build complete. Binaries in $(DIST_DIR)/"
test:
@echo "Running tests..."
go test ./... -v
@echo "All tests passed."
test-integration: build
@echo "Running integration tests against dist/pipekit..."
go test ./integration/... -v
@echo "Integration tests passed."
vuln:
@echo "Running govulncheck..."
govulncheck ./...
@echo "No called vulnerabilities found."
lint:
@echo "Running linter..."
golangci-lint run --timeout=5m
tidy:
go mod tidy
clean:
@echo "Cleaning build artifacts..."
rm -rf $(DIST_DIR)
@echo "Clean complete."
version:
@echo "Current version: $(VERSION)"
@echo "Build time: $(BUILD_TIME)"
@echo "Git commit: $(GIT_COMMIT)"
tag:
@if [ "$(VERSION)" = "dev" ]; then \
echo "Error: Cannot tag dev version. Please set VERSION environment variable."; \
exit 1; \
fi
@echo "Creating git tag: $(VERSION)"
git tag -a $(VERSION) -m "Release $(VERSION)"
@echo "Tag created. Push with: git push origin $(VERSION)"
release-check: test-integration vuln
@echo "Running tests..."
go test ./...
@echo "All tests passed. Ready for release $(VERSION)"
ci: tidy lint test build