-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (72 loc) · 2.73 KB
/
Makefile
File metadata and controls
88 lines (72 loc) · 2.73 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
.PHONY: build build-all test test-coverage clean install uninstall dev fmt tidy deps lint release checksums tag
BINARY_NAME=github-fork-manager
VERSION?=dev
LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION)"
GO?=$(shell which go || echo go)
GOFLAGS=-trimpath
PREFIX?=$(HOME)/.local
INSTALL_DIR=$(PREFIX)/bin
# Build for current platform
build:
$(GO) build $(GOFLAGS) $(LDFLAGS) -o $(BINARY_NAME) ./cmd/github-fork-manager
# Build for common platforms
build-all:
mkdir -p dist
GOOS=linux GOARCH=amd64 $(GO) build $(GOFLAGS) $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-amd64 ./cmd/github-fork-manager
GOOS=linux GOARCH=arm64 $(GO) build $(GOFLAGS) $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-arm64 ./cmd/github-fork-manager
GOOS=darwin GOARCH=amd64 $(GO) build $(GOFLAGS) $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-amd64 ./cmd/github-fork-manager
GOOS=darwin GOARCH=arm64 $(GO) build $(GOFLAGS) $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-arm64 ./cmd/github-fork-manager
GOOS=windows GOARCH=amd64 $(GO) build $(GOFLAGS) $(LDFLAGS) -o dist/$(BINARY_NAME)-windows-amd64.exe ./cmd/github-fork-manager
@echo "Built dist artifacts with VERSION=$(VERSION)"
# Run tests
test:
$(GO) test -v -cover ./...
# Run tests with coverage report
test-coverage:
$(GO) test -v -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
# Clean build artifacts
clean:
rm -f $(BINARY_NAME)
rm -rf dist/
rm -f coverage.out coverage.html
# Install to ~/.local/bin (or custom PREFIX)
install: build
@mkdir -p $(INSTALL_DIR)
@cp $(BINARY_NAME) $(INSTALL_DIR)/$(BINARY_NAME)
@echo "Installed to $(INSTALL_DIR)/$(BINARY_NAME)"
@echo "Ensure $(INSTALL_DIR) is on your PATH"
# Uninstall from installation directory
uninstall:
@echo "Uninstalling $(BINARY_NAME) from $(INSTALL_DIR)..."
@rm -f $(INSTALL_DIR)/$(BINARY_NAME)
@echo "✓ Uninstalled"
@echo "To remove configuration: rm -rf ~/.github-fork-manager"
# Run in development mode with optional ARGS
dev:
$(GO) run ./cmd/github-fork-manager $(ARGS)
# Format code
fmt:
$(GO) fmt ./...
gofmt -s -w .
# Tidy dependencies
tidy:
$(GO) mod tidy
# Download dependencies
deps:
$(GO) mod download
# Lint (requires golangci-lint installed)
lint:
golangci-lint run
# Checksums for release artifacts
checksums:
cd dist && shasum -a 256 * > checksums.txt
@echo "Wrote dist/checksums.txt"
# Tag the repo; set SKIP_PUSH=1 to avoid pushing
tag:
@test "$(VERSION)" != "dev" || (echo "Set VERSION=vX.Y.Z for release" && exit 1)
git tag -a "$(VERSION)" -m "Release $(VERSION)"
@if [ -z "$${SKIP_PUSH}" ]; then git push origin "$(VERSION)"; else echo "SKIP_PUSH set; not pushing tag"; fi
# Release pipeline: build artifacts, checksums, and tag
release: clean test build-all checksums tag
@echo "Release artifacts ready in dist/"