-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (42 loc) · 1.62 KB
/
Copy pathMakefile
File metadata and controls
59 lines (42 loc) · 1.62 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
MODULE := github.com/biao29/umeng-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")
LDFLAGS := -s -w \
-X $(MODULE)/internal/version.Version=$(VERSION) \
-X $(MODULE)/internal/version.Commit=$(COMMIT) \
-X $(MODULE)/internal/version.Date=$(DATE)
BUILD_FLAGS := -trimpath -ldflags "$(LDFLAGS)"
.PHONY: build install test vet fmt fmt-check tidy tidy-check replace-check release-check release release-dry clean sync-skill
build:
go build $(BUILD_FLAGS) -o bin/umeng ./cmd/umeng
install:
go install $(BUILD_FLAGS) ./cmd/umeng
test:
go test ./... -count=1
vet:
go vet ./...
fmt:
gofmt -w .
fmt-check:
@test -z "$$(gofmt -l .)" || (echo "Files need formatting:" && gofmt -l . && exit 1)
tidy:
go mod tidy
tidy-check:
@cp go.mod go.mod.bak && cp go.sum go.sum.bak && \
trap 'mv -f go.mod.bak go.mod 2>/dev/null; mv -f go.sum.bak go.sum 2>/dev/null' EXIT && \
go mod tidy && diff -q go.mod go.mod.bak > /dev/null && diff -q go.sum go.sum.bak > /dev/null || \
(echo "go.mod/go.sum not tidy or tidy failed" && exit 1)
replace-check:
@if grep -q '^replace' go.mod; then echo "ERROR: go.mod contains replace directives" && exit 1; fi
release-check: fmt-check vet tidy-check replace-check test
release:
@test -n "$(V)" || (echo "Usage: make release V=v0.1.0" && exit 1)
@scripts/release.sh $(V)
release-dry:
goreleaser release --snapshot --clean
clean:
rm -rf bin/
sync-skill:
@ln -sf ../../skills/umeng/SKILL.md internal/skills/SKILL.md
@echo "Skill synced"