-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (67 loc) · 2.38 KB
/
Makefile
File metadata and controls
82 lines (67 loc) · 2.38 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
.PHONY: all build clean test lint install uninstall release snapshot help
BINARY_NAME=ftv
INSTALL_PATH=/usr/local/bin
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS=-ldflags="-s -w -X main.version=$(VERSION)"
all: build
## build: Build the binary
build:
@echo "Building $(BINARY_NAME)..."
@go build $(LDFLAGS) -o $(BINARY_NAME)
## clean: Remove build artifacts
clean:
@echo "Cleaning..."
@rm -f $(BINARY_NAME)
@rm -rf dist/
## test: Run tests
test:
@echo "Running tests..."
@go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
## lint: Run linters
lint:
@echo "Running linters..."
@which golangci-lint > /dev/null || (echo "golangci-lint not found. Install: https://golangci-lint.run/usage/install/" && exit 1)
@golangci-lint run
## install: Install the binary to system
install: build
@echo "Installing $(BINARY_NAME) to $(INSTALL_PATH)..."
@sudo cp $(BINARY_NAME) $(INSTALL_PATH)/
@echo "✓ Installed successfully"
## uninstall: Remove the binary from system
uninstall:
@echo "Uninstalling $(BINARY_NAME) from $(INSTALL_PATH)..."
@sudo rm -f $(INSTALL_PATH)/$(BINARY_NAME)
@echo "✓ Uninstalled successfully"
## release: Create a new release (requires goreleaser)
release:
@which goreleaser > /dev/null || (echo "goreleaser not found. Install: https://goreleaser.com/install/" && exit 1)
@echo "Creating release..."
@goreleaser release --clean
## snapshot: Create a snapshot release (local testing)
snapshot:
@which goreleaser > /dev/null || (echo "goreleaser not found. Install: https://goreleaser.com/install/" && exit 1)
@echo "Creating snapshot..."
@goreleaser release --snapshot --clean
## run: Build and run with sample data
run: build
@./$(BINARY_NAME) --help
## deps: Download dependencies
deps:
@echo "Downloading dependencies..."
@go mod download
@go mod tidy
## check: Run tests and linters
check: test lint
## version: Update version in all files
version:
@echo "Updating version to $(VERSION)..."
@sed -i "" "s/version: '.*'/version: '$(VERSION)'/g" snap/snapcraft.yaml
@sed -i "" "s/v[0-9]\.[0-9]\.[0-9]/v$(VERSION)/g" README.md
@sed -i "" "s/Version: \".*\"/Version: \"$(VERSION)\"/g" ftv.go
@sed -i "" "s/pkgver=.*/pkgver=$(VERSION)/g" PKGBUILD
## help: Show this help message
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@sed -n 's/^##//p' $(MAKEFILE_LIST) | column -t -s ':' | sed -e 's/^/ /'