-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (92 loc) · 2.9 KB
/
Makefile
File metadata and controls
112 lines (92 loc) · 2.9 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# CloudAMQP CLI Makefile
# Variables
BINARY_NAME=cloudamqp
GO_BUILD_FLAGS=-v
GO_TEST_FLAGS=-v
# Version information (automatically extracted from git)
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_DATE ?= $(shell date -u +"%Y-%m-%d")
GIT_COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
# Build with version information
GO_LDFLAGS=-X cloudamqp-cli/cmd.Version=$(VERSION) \
-X cloudamqp-cli/cmd.BuildDate=$(BUILD_DATE) \
-X cloudamqp-cli/cmd.GitCommit=$(GIT_COMMIT)
bin/cloudamqp:
$(MAKE) build BINARY_NAME="bin/cloudamqp"
# Default target
.PHONY: all
all: build
# Build the binary
.PHONY: build
build:
go build $(GO_BUILD_FLAGS) -ldflags "$(GO_LDFLAGS)" -o $(BINARY_NAME) .
# Run tests
.PHONY: test
test:
go test $(GO_TEST_FLAGS) ./...
# Run integration tests
.PHONY: integration-test
integration-test:
go test $(GO_TEST_FLAGS) -tags=integration .
# Clean build artifacts
.PHONY: clean
clean:
rm -f $(BINARY_NAME)
go clean
# Format code
.PHONY: fmt
fmt:
go fmt ./...
# Vet code
.PHONY: vet
vet:
go vet ./...
# Install dependencies
.PHONY: deps
deps:
go mod download
go mod tidy
# Install the binary
.PHONY: install
install: build
go install .
# Build for multiple platforms
.PHONY: build-all
build-all:
GOOS=linux GOARCH=amd64 go build -ldflags "$(GO_LDFLAGS)" -o $(BINARY_NAME)-linux-amd64 .
GOOS=darwin GOARCH=amd64 go build -ldflags "$(GO_LDFLAGS)" -o $(BINARY_NAME)-darwin-amd64 .
GOOS=darwin GOARCH=arm64 go build -ldflags "$(GO_LDFLAGS)" -o $(BINARY_NAME)-darwin-arm64 .
GOOS=windows GOARCH=amd64 go build -ldflags "$(GO_LDFLAGS)" -o $(BINARY_NAME)-windows-amd64.exe .
# Development workflow
.PHONY: dev
dev: fmt vet test build
# Show version information that will be used
.PHONY: version-info
version-info:
@echo "Version Info:"
@echo " VERSION: $(VERSION)"
@echo " BUILD_DATE: $(BUILD_DATE)"
@echo " GIT_COMMIT: $(GIT_COMMIT)"
openapi.yaml:
curl -O https://docs.cloudamqp.com/openapi.yaml
openapi-instance.yaml:
curl -O https://docs.cloudamqp.com/openapi-instance.yaml
# Help target
.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build the binary with version info"
@echo " test - Run tests"
@echo " integration-test - Run integration tests"
@echo " clean - Clean build artifacts"
@echo " fmt - Format code"
@echo " vet - Vet code"
@echo " deps - Install dependencies"
@echo " install - Install the binary"
@echo " build-all - Build for multiple platforms with version info"
@echo " dev - Run development workflow (fmt, vet, test, build)"
@echo " version-info - Show version information that will be used in build"
@echo " help - Show this help message"
@echo ""
@echo "Version information is automatically extracted from git."
@echo "Override with: make build VERSION=1.0.0 BUILD_DATE=2025-11-25"