-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (82 loc) · 3.43 KB
/
Copy pathMakefile
File metadata and controls
97 lines (82 loc) · 3.43 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
# ==============================================================================
# Cortex Index — Build, Install & Execution Makefile
# ==============================================================================
# Variables
BINARY_NAME=cortex
BUILD_DIR=bin
GO_MAIN=./cmd/cortex
RELEASE_DIR=release
VERSION?=$(shell cat VERSION 2>/dev/null || echo "0.0.0-dev")
LDFLAGS=-ldflags="-s -w -X main.version=$(shell cat VERSION 2>/dev/null || echo dev)"
.PHONY: all build build-backend build-ui dist install clean test help
all: build
## build: Build backend binary + UI bundle
build: build-backend build-ui
## build-backend: Compile Go cortex binary to bin/cortex
build-backend:
@echo "==> Building cortex v$(VERSION)..."
@mkdir -p $(BUILD_DIR)
go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) $(GO_MAIN)
@echo "✓ Built at $(BUILD_DIR)/$(BINARY_NAME) (v$(VERSION))"
## build-ui: Build UI Vite bundle with Bun
build-ui:
@echo "==> Building UI..."
@cd ui && bun install && bun run build
@echo "✓ UI built"
## dist: Package binary + UI + install.sh into release/cortex.tar.gz
dist: clean build-backend build-ui
@echo "==> Packaging release v$(VERSION)..."
@mkdir -p $(RELEASE_DIR)/cortex/ui
@cp $(BUILD_DIR)/$(BINARY_NAME) $(RELEASE_DIR)/cortex/
@cp install.sh $(RELEASE_DIR)/cortex/
@if [ -d "ui/dist" ]; then \
cp -r ui/dist $(RELEASE_DIR)/cortex/ui/; \
fi
@cd $(RELEASE_DIR) && tar czf cortex.tar.gz cortex/
@rm -rf $(RELEASE_DIR)/cortex
@echo "✓ Packaged at $(RELEASE_DIR)/cortex.tar.gz"
## install: Extract dist to ~/.cortex/ and add to PATH (single source of truth)
install: dist
@echo "==> Installing cortex v$(VERSION)..."
@mkdir -p $(HOME)/.cortex/bin $(HOME)/.cortex/ui
@tar xzf $(RELEASE_DIR)/cortex.tar.gz -C /tmp/cortex-install 2>/dev/null || true
@mkdir -p /tmp/cortex-install
@tar xzf $(RELEASE_DIR)/cortex.tar.gz -C /tmp/cortex-install
@cp /tmp/cortex-install/cortex/cortex $(HOME)/.cortex/bin/cortex
@chmod +x $(HOME)/.cortex/bin/cortex
@if [ -d "/tmp/cortex-install/cortex/ui/dist" ]; then \
rm -rf $(HOME)/.cortex/ui/dist; \
cp -r /tmp/cortex-install/cortex/ui/dist $(HOME)/.cortex/ui/; \
fi
@rm -rf /tmp/cortex-install
@echo "✓ Installed to $(HOME)/.cortex/bin/cortex"
@echo " Add to PATH: export PATH=\"$$HOME/.cortex/bin:\$$PATH\""
## clean: Remove build artifacts
clean:
@rm -rf $(BUILD_DIR) $(RELEASE_DIR) ui/dist
## test: Run Go tests + UI typecheck
test:
@echo "==> Running tests..."
go test ./...
@cd ui && bun run lint
## version: Show current version
version:
@cat VERSION
## patch: Increment patch version (x.y.Z)
patch:
@v=$$(cat VERSION); a=$$(echo $$v | cut -d. -f1); b=$$(echo $$v | cut -d. -f2); c=$$(echo $$v | cut -d. -f3); new="$$a.$$b.$$((c + 1))"; echo "$$new" > VERSION; echo "✓ $$v → $$new"
## minor: Increment minor version (x.Y.z)
minor:
@v=$$(cat VERSION); a=$$(echo $$v | cut -d. -f1); b=$$(echo $$v | cut -d. -f2); new="$$a.$$((b + 1)).0"; echo "$$new" > VERSION; echo "✓ $$v → $$new"
## major: Increment major version (X.y.z)
major:
@v=$$(cat VERSION); a=$$(echo $$v | cut -d. -f1); new="$$((a + 1)).0.0"; echo "$$new" > VERSION; echo "✓ $$v → $$new"
## help: Show help
help:
@echo "Cortex Index Makefile:"
@echo " make build Build binary + UI"
@echo " make dist Package release/cortex.tar.gz"
@echo " make install Install to ~/.cortex/bin/cortex"
@echo " make test Run tests"
@echo " make clean Remove build artifacts"
@echo " make version Show version"