-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (60 loc) · 1.46 KB
/
Makefile
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
.PHONY: build test clean install release snapshot
# Build variables
BINARY_NAME=take-cli
VERSION=$(shell git describe --tags --always --dirty)
COMMIT=$(shell git rev-parse HEAD)
DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS=-ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}"
# Go commands
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOINSTALL=$(GOCMD) install
# Build the binary
build:
$(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME) ./cmd/take
# Run tests
test:
$(GOTEST) -v -race ./...
# Run tests with coverage
test-coverage:
$(GOTEST) -v -race -coverprofile=coverage.txt -covermode=atomic ./...
# Clean build artifacts
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f coverage.txt
# Install the binary
install:
$(GOINSTALL) $(LDFLAGS) ./cmd/take
# Create a snapshot release
snapshot:
goreleaser release --snapshot --rm-dist
# Create a release
release:
goreleaser release --rm-dist
# Install development dependencies
dev-deps:
$(GOGET) -u golang.org/x/lint/golint
$(GOGET) -u github.com/goreleaser/goreleaser
# Run linter
lint:
golint ./...
# Format code
fmt:
go fmt ./...
# Run all checks
check: fmt lint test
# Generate shell completions
completions:
mkdir -p completions
cp completions/take.{bash,zsh,fish} completions/
# Install shell integration
install-shell:
ifeq ($(OS),Windows_NT)
powershell -ExecutionPolicy Bypass -File scripts/install.ps1
else
bash scripts/install.sh
endif