forked from profclems/glab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (42 loc) · 1.71 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
GLAB_VERSION ?= $(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD)
DATE_FMT = +%Y-%m-%d
ifdef SOURCE_DATE_EPOCH
BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)")
else
BUILD_DATE ?= $(shell date "$(DATE_FMT)")
endif
ifndef CGO_CPPFLAGS
export CGO_CPPFLAGS := $(CPPFLAGS)
endif
ifndef CGO_CFLAGS
export CGO_CFLAGS := $(CFLAGS)
endif
ifndef CGO_LDFLAGS
export CGO_LDFLAGS := $(LDFLAGS)
endif
GO_LDFLAGS := -X main.build=$(BUILD_DATE) $(GO_LDFLAGS)
GO_LDFLAGS := $(GO_LDFLAGS) -X main.version=$(GLAB_VERSION)
GOURL ?= github.com/profclems/glab
BUILDLOC ?= ./bin/glab
build:
go build -trimpath -ldflags "$(GO_LDFLAGS) -X main.usageMode=prod" -o $(BUILDLOC) $(GOURL)/cmd/glab
install:
GO111MODULE=on go install -trimpath -ldflags "$(GO_LDFLAGS)-sources -X main.usageMode=prod" $(GOURL)/cmd/glab
run:
go run -trimpath -ldflags "$(GO_LDFLAGS) -X main.usageMode=dev" ./cmd/glab $(var)
tests:
bash -c "trap 'trap - SIGINT SIGTERM ERR; rm coverage-* 2>&1 > /dev/null; exit 1' SIGINT SIGTERM ERR; $(MAKE) internal-test"
internal-test:
rm coverage-* 2>&1 > /dev/null || true
GO111MODULE=on go test -coverprofile=coverage-main.out -covermode=count -coverpkg ./... -run=$(run) $(GOURL)/cmd/glab $(GOURL)/commands $(GOURL)/internal/...
go get -u github.com/wadey/gocovmerge
gocovmerge coverage-*.out > coverage.txt && rm coverage-*.out
rt: #Test release
goreleaser --snapshot --skip-publish --rm-dist
rtdebug: #Test release
goreleaser --snapshot --skip-publish --rm-dist --debug
release:
goreleaser $(var)
gen-docs:
go run ./cmd/gen-docs/docs.go
cp ./docs/glab.md ./docs/index.md