-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (58 loc) · 2.17 KB
/
Copy pathMakefile
File metadata and controls
73 lines (58 loc) · 2.17 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
.PHONY: build install clean test run build-all release help
# Binary name
BINARY_NAME=dusty
# Build flags
LDFLAGS=-ldflags="-s -w"
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
build: ## Build binary for current platform
go build $(LDFLAGS) -o $(BINARY_NAME)
install: ## Install binary to $GOPATH/bin
go install $(LDFLAGS)
run: ## Run the application on current directory
go run .
test: ## Run tests
go test -v ./...
clean: ## Remove built binaries and dist directory
rm -f $(BINARY_NAME)
rm -f $(BINARY_NAME)-*
rm -rf dist/
build-all: ## Build for all platforms (Linux, macOS, Windows)
@echo "Building for all platforms..."
@mkdir -p dist
@echo "Building for Linux amd64..."
@GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-amd64
@echo "Building for Linux arm64..."
@GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-arm64
@echo "Building for macOS amd64..."
@GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-amd64
@echo "Building for macOS arm64..."
@GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-arm64
@echo "Building for Windows amd64..."
@GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-windows-amd64.exe
@echo "Building for Windows arm64..."
@GOOS=windows GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-windows-arm64.exe
@echo "Done! Binaries are in dist/"
@ls -lh dist/
release: ## Tag and push a release; GoReleaser publishes it (usage: make release VERSION=v0.7.0)
ifndef VERSION
$(error VERSION is required, e.g. make release VERSION=v0.7.0)
endif
go test ./...
git tag -a $(VERSION) -m "Release $(VERSION)"
git push origin $(VERSION)
@echo $(VERSION) pushed - GitHub Actions (GoReleaser) is now building and publishing the release
fmt: ## Format Go code
go fmt ./...
vet: ## Run go vet
go vet ./...
lint: fmt vet ## Run formatting and vetting
deps: ## Download dependencies
go mod download
go mod tidy
upgrade-deps: ## Upgrade all dependencies
go get -u ./...
go mod tidy