-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
71 lines (53 loc) · 1.54 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
unexport GOFLAGS
GOOS?=linux
TESTOPTS ?=
GOARCH?=amd64
GOENV=GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 GOFLAGS=
GOPATH := $(shell go env GOPATH)
HOME?=$(shell mktemp -d)
GOLANGCI_LINT_VERSION=v1.51.2
GORELEASER_VERSION=v1.24.0
export GITHUB_TOKEN?=$(shell jq -r .goreleaser_token ~/.config/goreleaser/goreleaser_token)
# Ensure go modules are enabled:
export GO111MODULE=on
export GOPROXY=https://proxy.golang.org
# Disable CGO so that we always generate static binaries:
export CGO_ENABLED=0
.PHONY: build
build:
goreleaser build --snapshot --clean --single-target
.PHONY: install
install:
go build -o ${GOPATH}/bin/srepd .
.PHONY: install-local
install-local: build
cp dist/*/srepd ~/.local/bin/srepd
.PHONY: mod
mod:
go mod tidy
.PHONY: test
test:
go test ./... -v $(TESTOPTS)
.PHONY: coverage
coverage:
hack/codecov.sh
# Installed using instructions from: https://golangci-lint.run/usage/install/#linux-and-windows
getlint:
@mkdir -p $(GOPATH)/bin
@ls $(GOPATH)/bin/golangci-lint 1>/dev/null || (echo "Installing golangci-lint..." && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION))
.PHONY: lint
lint: getlint
$(GOPATH)/bin/golangci-lint run --timeout 5m
ensure-goreleaser:
@ls $(GOPATH)/bin/goreleaser 1>/dev/null || go install github.com/goreleaser/goreleaser@${GORELEASER_VERSION}
release: ensure-goreleaser
goreleaser release --clean
.PHONY: fmt
fmt:
gofmt -s -l -w cmd pkg tests
.PHONY: clean
clean:
rm -rf \
build/*
rm -rf \
dist/*