-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (44 loc) · 1.45 KB
/
Makefile
File metadata and controls
55 lines (44 loc) · 1.45 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
BINARY := notion
MODULE := github.com/paoloanzn/neo-notion-cli
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
GOBIN ?= $(HOME)/.local/bin
LDFLAGS := -s -w \
-X $(MODULE)/internal/version.Version=$(VERSION) \
-X $(MODULE)/internal/version.Commit=$(COMMIT) \
-X $(MODULE)/internal/version.Date=$(DATE)
.PHONY: build install uninstall clean test lint fmt vet
## build: Compile the binary into ./bin/
build:
@mkdir -p bin
go build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) .
@echo "Built bin/$(BINARY)"
## install: Build and install the binary to ~/.local/bin (override with GOBIN=)
install:
@mkdir -p $(GOBIN)
go build -ldflags "$(LDFLAGS)" -o $(GOBIN)/$(BINARY) .
@echo "Installed $(GOBIN)/$(BINARY)"
## uninstall: Remove the binary from GOBIN
uninstall:
rm -f $(GOBIN)/$(BINARY)
@echo "Removed $(GOBIN)/$(BINARY)"
## clean: Remove build artifacts
clean:
rm -rf bin/
go clean
## test: Run all tests
test:
go test -race -count=1 ./...
## lint: Run go vet and staticcheck (if available)
lint: vet
@command -v staticcheck >/dev/null 2>&1 && staticcheck ./... || echo "staticcheck not installed, skipping"
## vet: Run go vet
vet:
go vet ./...
## fmt: Format all Go source files
fmt:
gofmt -s -w .
## help: Show this help
help:
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## //' | column -t -s ':'