-
-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (54 loc) · 2.39 KB
/
Makefile
File metadata and controls
74 lines (54 loc) · 2.39 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
# MoAI-ADK Go Edition
# Build and development automation
BINARY_NAME := moai
MODULE := github.com/modu-ai/moai-adk
VERSION ?= $(shell git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -ldflags "-s -w -X $(MODULE)/pkg/version.Version=$(VERSION) -X $(MODULE)/pkg/version.Commit=$(COMMIT) -X $(MODULE)/pkg/version.Date=$(DATE)"
# Local release configuration
LOCAL_RELEASE_DIR ?= $(HOME)/.moai/releases
PLATFORM := $(shell go env GOOS)-$(shell go env GOARCH)
RELEASE_BINARY := moai-$(VERSION)-$(PLATFORM)
.PHONY: all build test lint fix clean install generate help release-local
all: lint test build ## Run lint, test, and build
build: ## Build the binary
go build $(LDFLAGS) -o bin/$(BINARY_NAME) ./cmd/moai
release-local: build ## Create a local release for development updates
@echo "Creating local release: $(VERSION)"
@mkdir -p $(LOCAL_RELEASE_DIR)
@cp bin/$(BINARY_NAME) $(LOCAL_RELEASE_DIR)/$(RELEASE_BINARY)
@chmod +x $(LOCAL_RELEASE_DIR)/$(RELEASE_BINARY)
@echo '{"version":"$(VERSION)","date":"$(DATE)","platform":"$(PLATFORM)","binary":"$(RELEASE_BINARY)"}' > $(LOCAL_RELEASE_DIR)/version.json
@echo "Local release created at: $(LOCAL_RELEASE_DIR)"
@echo " Binary: $(RELEASE_BINARY)"
@echo " Version: $(VERSION)"
install: ## Install the binary
go install $(LDFLAGS) ./cmd/moai
test: ## Run tests with race detection
go test -race -coverprofile=coverage.out -covermode=atomic ./...
test-verbose: ## Run tests with verbose output
go test -race -v -coverprofile=coverage.out -covermode=atomic ./...
coverage: test ## Show test coverage report
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
lint: ## Run linters
golangci-lint run ./...
fix: ## Run go fix modernizers (twice for synergistic fixes)
go fix ./...
go fix ./...
vet: ## Run go vet
go vet ./...
fmt: ## Format code
gofumpt -l -w .
generate: ## Run go generate
go generate ./...
clean: ## Remove build artifacts
rm -rf bin/ coverage.out coverage.html
tidy: ## Tidy go modules
go mod tidy
run: build ## Build and run
./bin/$(BINARY_NAME)
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help