generated from deweysasser/golang-program
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (42 loc) · 1.28 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
ifeq ($(OS),Windows_NT)
EXE=.exe
else
EXE=
endif
BASENAME=$(notdir $(shell pwd))
PROGRAM=$(BASENAME)$(EXE)
LAST_RELEASE=
REPO=$(shell go list | head -n 1)
IMAGE=$(BASENAME)
VERSION ?= $(shell git describe --tags --always --dirty)
DOCKER=docker
.PHONY: $(PROGRAM)
all: $(PROGRAM)
compile: $(PROGRAM)
$(PROGRAM):
go build -ldflags="-X '$(REPO)/program.Version=${VERSION}'" -o $(PROGRAM)
install:
go install -ldflags="-X '$(REPO)/program.Version=${VERSION}'"
image: Dockerfile
$(DOCKER) build --build-arg PROGRAM=$(BASENAME) --build-arg VERSION=$(VERSION) --build-arg BASENAME=$(BASENAME) -t $(IMAGE) .
test:
go test -v ./...
vet:
go vet ./...
changelog: CHANGELOG.md
CHANGELOG.md: .chglog/config.yml
git chglog $(LAST_RELEASE) >$@
.chglog/config.yml: go.mod
sed -i.bak -e "s/repository_url:.*/repository_url: $(REPO)/" $@
hooks: .git/hooks/pre-commit
.git/hooks/pre-commit: .pre-commit-config.yaml
pre-commit install
pre-commit install --hook-type commit-msg
info::
@echo BASENAME=$(BASENAME)
@echo PROGRAM=$(PROGRAM)
@echo IMAGE=$(IMAGE)
tools:
go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/go-critic/go-critic/cmd/gocritic@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest