-
Notifications
You must be signed in to change notification settings - Fork 44
/
Makefile
54 lines (42 loc) · 1.21 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
.DEFAULT_GOAL := build
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
BINARY_NAME=weep
VERSION=dev-$(shell date +%Y%m%d%H%M%S)
REGISTRY=$(REGISTRY)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
ifneq ($(BRANCH),master)
VERSION_PRERELEASE=$(BRANCH)
endif
export VERSION
export VERSION_PRERELEASE
ifneq ($(VERSION_PRERELEASE),)
DOCKER_TAG=v$(VERSION)-$(VERSION_PRERELEASE)
else
DOCKER_TAG=v$(VERSION)
endif
.PHONY: build
build:
@BINARY_NAME="$(BINARY_NAME)" sh -c "'$(CURDIR)/scripts/build.sh'"
.PHONY: release
release:
@BINARY_NAME="$(BINARY_NAME)" LD_FLAGS='-s -w' sh -c "'$(CURDIR)/scripts/build.sh'"
upx $(BINARY_NAME)
.PHONY: weep-docker
weep-docker:
@BINARY_NAME="$(BINARY_NAME)-docker" GOOS=linux LD_FLAGS='-s -w -extldflags "-static"' sh -c "'$(CURDIR)/scripts/build.sh'"
.PHONY: build-docker
build-docker: weep-docker
docker build -t weep .
docker tag weep:latest $(REGISTRY)/infrasec/weep:$(DOCKER_TAG)
.PHONY: docker
docker: build-docker
.PHONY: fmtcheck
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
.PHONY: fmt
fmt:
gofmt -w $(GOFMT_FILES)
.PHONY: clean
clean:
@if [ -f $(BINARY_NAME) ] ; then rm $(BINARY_NAME) ; fi
@if [ -f $(BINARY_NAME)-docker ] ; then rm $(BINARY_NAME)-docker ; fi