-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
45 lines (35 loc) · 897 Bytes
/
Copy pathMakefile
File metadata and controls
45 lines (35 loc) · 897 Bytes
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
VERSION := $(shell git describe --tags --exact-match 2>/dev/null || echo "dev")
TARGET := git-zf
BIN_DIR := ./bin
BIN := $(BIN_DIR)/$(TARGET)
GOARCH := $(shell go env GOARCH)
LDFLAGS := -ldflags "-X github.com/piprim/git-zf/cmd.Version=${VERSION}"
ifeq ($(OS),Windows_NT)
GOOS := windows
COPY := copy
RM := del /Q /F
else
COPY := cp
RM := rm -f
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
GOOS := linux
else ifeq ($(UNAME_S),Darwin)
GOOS := darwin
endif
endif
GIT_EXEC_PATH := $(shell git --exec-path)
all: build
install: build
$(COPY) $(BIN) $(GIT_EXEC_PATH)/$(TARGET)
uninstall:
$(RM) $(GIT_EXEC_PATH)/$(TARGET)
clean:
rm -rf $(BIN_DIR)
build:
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o $(BIN) ${LDFLAGS}
test:
go tool gotestsum --format testdox -- -v ./...
lint:
golangci-lint run ./...
.PHONY: all install clean build test lint