-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
172 lines (152 loc) · 6.27 KB
/
Copy pathMakefile
File metadata and controls
172 lines (152 loc) · 6.27 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Copyright 2025 Christopher O'Connell
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
.PHONY: build install install-completion docker docker-web signing-image clean test check help release release-snapshot license-check build-relay docker-relay
# Default target
help:
@echo "Maestro Build Targets:"
@echo " make check - Compile all binaries and run all tests (no Docker needed)"
@echo " make build - Build the maestro binary"
@echo " make docker - Build the Docker image locally"
@echo " make signing-image - Build the code signing Docker image"
@echo " make install - Install maestro to /usr/local/bin (requires sudo)"
@echo " make install-completion - Install shell completion for current shell"
@echo " make test - Run tests"
@echo " make clean - Remove built binaries"
@echo " make all - Build everything (binary + docker)"
@echo " make build-relay - Build the signal-relay binary"
@echo " make docker-relay - Build the signal-relay Docker image"
@echo " make license-check - Check/add Apache 2.0 headers to source files"
@echo ""
@echo "Release Targets:"
@echo " make release-preflight - Check release prerequisites"
@echo " make release-preflight-snapshot - Check snapshot prerequisites"
@echo " make release VERSION=vX.Y.Z - Create a new release (runs preflight)"
@echo " make release-snapshot - Test release build without publishing"
# Version information for dev builds
VERSION ?= dev
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -X github.com/uprockcom/maestro/pkg/version.Version=$(VERSION) \
-X github.com/uprockcom/maestro/pkg/version.Commit=$(COMMIT) \
-X github.com/uprockcom/maestro/pkg/version.Date=$(DATE) \
-X github.com/uprockcom/maestro/pkg/version.BuiltBy=make
# Build the Go binary
build:
mkdir -p bin
go build -ldflags "$(LDFLAGS)" -o bin/maestro .
# Build the Docker image
docker:
docker build -t maestro:latest -f docker/Dockerfile .
# Build the Web-enabled Docker image
docker-web: docker
docker build -t maestro-web:latest --build-arg BASE_IMAGE=maestro:latest -f docker/Dockerfile.web .
# Build the code signing Docker image
# Tagged with version and latest
SIGNING_IMAGE_VERSION ?= 1.0.0
signing-image:
@echo "Building signing tools container..."
docker build \
-t maestro-signing:$(SIGNING_IMAGE_VERSION) \
-t maestro-signing:latest \
-f docker/signing/Dockerfile \
docker/signing/
@echo "✓ Built: maestro-signing:$(SIGNING_IMAGE_VERSION)"
@echo "✓ Tagged: maestro-signing:latest"
# Install to system PATH (run 'make build' first, then 'sudo make install')
install:
cp bin/maestro /usr/local/bin/
@echo ""
@echo "Run 'make install-completion' to enable shell autocompletion"
# Install shell completion for current shell
install-completion:
@if [ ! -f bin/maestro ]; then \
echo "Error: bin/maestro not found. Run 'make build' first."; \
exit 1; \
fi
@SHELL_NAME=$$(basename "$$SHELL"); \
case "$$SHELL_NAME" in \
bash) \
echo "Installing bash completion..."; \
mkdir -p ~/.local/share/bash-completion/completions; \
bin/maestro completion bash > ~/.local/share/bash-completion/completions/maestro; \
echo "Installed to ~/.local/share/bash-completion/completions/maestro"; \
echo "Run 'source ~/.local/share/bash-completion/completions/maestro' or restart your shell"; \
;; \
zsh) \
echo "Installing zsh completion..."; \
mkdir -p ~/.zsh/completions; \
bin/maestro completion zsh > ~/.zsh/completions/_maestro; \
echo "Installed to ~/.zsh/completions/_maestro"; \
echo "Add 'fpath=(~/.zsh/completions \$$fpath)' to ~/.zshrc if not already present"; \
echo "Then run 'autoload -U compinit && compinit' or restart your shell"; \
;; \
fish) \
echo "Installing fish completion..."; \
mkdir -p ~/.config/fish/completions; \
bin/maestro completion fish > ~/.config/fish/completions/maestro.fish; \
echo "Installed to ~/.config/fish/completions/maestro.fish"; \
;; \
*) \
echo "Unknown shell: $$SHELL_NAME"; \
echo "Run 'maestro completion --help' for manual installation instructions"; \
;; \
esac
# Run tests
test:
go test ./...
# Compile all binaries and run all tests (works inside containers — no Docker needed)
check:
@echo "==> Compiling maestro (main module)..."
go build ./...
@echo "==> Compiling maestro-request (docker/maestro-request-go)..."
cd docker/maestro-request-go && go build -o /dev/null .
@echo "==> Compiling signal-relay (cmd/signal-relay)..."
cd cmd/signal-relay && go build -o /dev/null .
@echo "==> Running tests (main module)..."
go test ./...
@echo ""
@echo "All binaries compile and tests pass."
# Clean build artifacts
clean:
rm -rf bin
# Build the signal-relay binary (separate Go module)
build-relay:
cd cmd/signal-relay && go build -o ../../bin/signal-relay .
# Build the signal-relay Docker image
docker-relay:
docker build -t maestro-signal-relay:latest -f deploy/signal-relay/Dockerfile .
# Build everything
all: build docker docker-web docker-relay
# Release targets
release-preflight:
@chmod +x scripts/release-preflight.sh
@./scripts/release-preflight.sh --release
release-preflight-snapshot:
@chmod +x scripts/release-preflight.sh
@./scripts/release-preflight.sh --snapshot
release:
ifndef VERSION
@echo "Error: VERSION is required"
@echo "Usage: make release VERSION=v1.2.3"
@exit 1
endif
@chmod +x scripts/release.sh
@./scripts/release.sh $(VERSION)
release-snapshot:
@echo "Building snapshot release (no publish)..."
goreleaser release --snapshot --clean --skip=publish
# Check and add Apache 2.0 license headers
license-check:
@chmod +x scripts/add-license-headers.sh
@./scripts/add-license-headers.sh