forked from tierpod/dmarc-report-converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (38 loc) · 1.26 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
NAME := dmarc-report-converter
DESTDIR := /opt
INSTALLDIR := $(DESTDIR)/dmarc-report-converter
ARCH := $(shell arch)
ifeq ($(GITHUB_REF),)
GIT_VER := $(shell git describe --abbrev=7 --always --tags)-$(shell git rev-parse --abbrev-ref HEAD)-$(shell date +%Y%m%d)
else
GIT_VER := $(shell basename $(GITHUB_REF))-$(shell date +%Y%m%d)
endif
LDFLAGS := -ldflags "-X main.version=$(GIT_VER)"
CGO_ENABLED := 0
.PHONY: test
test:
find ./cmd ./pkg -type f -name '*.go' | xargs gofmt -l -e
go vet -mod=vendor ./cmd/... ./pkg/...
$(shell go env GOPATH)/bin/staticcheck ./cmd/... ./pkg/...
go test -mod=vendor ./cmd/... ./pkg/...
.PHONY: build
build: test bin/$(NAME)
bin/$(NAME):
CGO_ENABLED=$(CGO_ENABLED) go build -mod=vendor -v $(LDFLAGS) -o $@ ./cmd/$(NAME)
.PHONY: clean
clean:
rm -f bin/*
rm -f ./pprof
rm -rf ./tmp/dmarc-report-converter
.PHONY: install
install: $(INSTALLDIR) bin/$(NAME)
install -m 0755 bin/$(NAME) $(INSTALLDIR)
install -m 0600 config/config.dist.yaml $(INSTALLDIR)/config.dist.yaml
cp -r assets $(INSTALLDIR)
cp -r install $(INSTALLDIR)
$(INSTALLDIR) dist tmp:
mkdir -p $@
.PHONY: release
release: clean dist
make DESTDIR=./tmp install
tar -cvzf dist/$(NAME)_$(GIT_VER)_$(ARCH).tar.gz --owner=0 --group=0 -C ./tmp $(NAME)