Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (56 loc) · 1.97 KB
/
Copy pathMakefile
File metadata and controls
77 lines (56 loc) · 1.97 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
.PHONY: all build test test-race test-short clean install docker lint fmt vet release install-local
BINARY_NAME=lcre
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS=-ldflags "-X github.com/refractionPOINT/lcre/internal/cli.Version=$(VERSION) -X github.com/refractionPOINT/lcre/internal/cli.BuildTime=$(BUILD_TIME)"
all: build
build:
go build $(LDFLAGS) -o bin/$(BINARY_NAME) ./cmd/lcre
install:
go install $(LDFLAGS) ./cmd/lcre
test:
go test -v -cover ./...
test-race:
CGO_ENABLED=1 go test -v -race -cover ./...
test-short:
go test -v -short ./...
clean:
rm -rf bin/
rm -rf dist/
go clean -testcache
lint:
golangci-lint run ./...
fmt:
go fmt ./...
vet:
go vet ./...
tidy:
go mod tidy
# Docker targets
docker-build:
docker build -t $(BINARY_NAME):$(VERSION) .
docker-run:
docker run --rm -v $(PWD):/work $(BINARY_NAME):$(VERSION)
# Development helpers
dev: fmt vet test build
# Cross-compilation
build-all: build-linux build-darwin build-windows
build-linux:
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-linux-amd64 ./cmd/lcre
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-linux-arm64 ./cmd/lcre
build-darwin:
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-darwin-amd64 ./cmd/lcre
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-darwin-arm64 ./cmd/lcre
build-windows:
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o bin/$(BINARY_NAME)-windows-amd64.exe ./cmd/lcre
# Release builds for Linux (used by installer)
release: clean
@echo "Building release binaries..."
@mkdir -p dist
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-amd64 ./cmd/lcre
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-arm64 ./cmd/lcre
@echo "Release binaries created in dist/"
@ls -la dist/
# Local installation using the installer script
install-local:
@bash scripts/install.sh