Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (48 loc) · 1.58 KB
/
Copy pathMakefile
File metadata and controls
62 lines (48 loc) · 1.58 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
BINARY := entropy
PKG := ./cmd/entropy
GO ?= go
DEMO_HOME ?= $(CURDIR)/.demo
# Version metadata embedded into the binary (see internal/cli/version.go).
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -s -w \
-X github.com/yzoz/entropy/internal/cli.version=$(VERSION) \
-X github.com/yzoz/entropy/internal/cli.commit=$(COMMIT) \
-X github.com/yzoz/entropy/internal/cli.date=$(DATE)
.PHONY: build install test test-race lint fmt vet tidy demo run snapshot clean
## build: compile the CLI into ./bin/entropy with version metadata
build:
$(GO) build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) $(PKG)
## install: install the CLI into GOPATH/bin
install:
$(GO) install -ldflags "$(LDFLAGS)" $(PKG)
## test: run the full test suite
test:
$(GO) test ./...
## test-race: run the test suite under the race detector
test-race:
$(GO) test -race ./...
## vet: run go vet
vet:
$(GO) vet ./...
## fmt: format all Go sources
fmt:
gofmt -w ./cmd ./internal
## lint: run gofmt and vet
lint: fmt vet
## tidy: sync go.mod/go.sum
tidy:
$(GO) mod tidy
## demo: run the end-to-end scenario in a throwaway data dir
demo:
./scripts/demo.sh
## run: build and run the CLI (ARGS="..." make run)
run:
$(GO) run -ldflags "$(LDFLAGS)" $(PKG) $(ARGS)
## snapshot: build release artifacts locally with GoReleaser (no publish)
snapshot:
goreleaser release --snapshot --clean
## clean: remove build output and demo data
clean:
rm -rf bin dist $(DEMO_HOME)