forked from redpanda-data/connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
116 lines (90 loc) · 3.69 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
.PHONY: all serverless deps docker docker-cgo clean docs test test-race test-integration fmt lint install deploy-docs
TAGS =
INSTALL_DIR = $(GOPATH)/bin
DEST_DIR = ./target
PATHINSTBIN = $(DEST_DIR)/bin
PATHINSTSERVERLESS = $(DEST_DIR)/serverless
PATHINSTDOCKER = $(DEST_DIR)/docker
VERSION := $(shell git describe --tags || echo "v0.0.0")
VER_CUT := $(shell echo $(VERSION) | cut -c2-)
VER_MAJOR := $(shell echo $(VER_CUT) | cut -f1 -d.)
VER_MINOR := $(shell echo $(VER_CUT) | cut -f2 -d.)
VER_PATCH := $(shell echo $(VER_CUT) | cut -f3 -d.)
VER_RC := $(shell echo $(VER_PATCH) | cut -f2 -d-)
DATE := $(shell date +"%Y-%m-%dT%H:%M:%SZ")
VER_FLAGS = -X github.com/Jeffail/benthos/v3/lib/service.Version=$(VERSION) \
-X github.com/Jeffail/benthos/v3/lib/service.DateBuilt=$(DATE)
LD_FLAGS =
GO_FLAGS =
APPS = benthos
all: $(APPS)
install: $(APPS)
@cp $(PATHINSTBIN)/* $(INSTALL_DIR)/
deps:
@go mod tidy
@go mod vendor
$(PATHINSTBIN)/%: $(wildcard lib/*/*.go lib/*/*/*.go lib/*/*/*/*.go cmd/*/*.go)
@mkdir -p $(dir $@)
@go build $(GO_FLAGS) -tags "$(TAGS)" -ldflags "$(LD_FLAGS) $(VER_FLAGS)" -o $@ ./cmd/$*
$(APPS): %: $(PATHINSTBIN)/%
SERVERLESS = benthos-lambda
serverless: $(SERVERLESS)
$(PATHINSTSERVERLESS)/%: $(wildcard lib/*/*.go lib/*/*/*.go lib/*/*/*/*.go cmd/serverless/*/*.go)
@mkdir -p $(dir $@)
@GOOS=linux go build $(GO_FLAGS) -tags "$(TAGS)" -ldflags "$(LD_FLAGS) $(VER_FLAGS)" -o $@ ./cmd/serverless/$*
@zip -m -j [email protected] $@
$(SERVERLESS): %: $(PATHINSTSERVERLESS)/%
docker-tags:
@echo "latest,$(VER_CUT),$(VER_MAJOR).$(VER_MINOR),$(VER_MAJOR)" > .tags
docker-rc-tags:
@echo "latest,$(VER_CUT),$(VER_MAJOR)-$(VER_RC)" > .tags
docker-cgo-tags:
@echo "latest-cgo,$(VER_CUT)-cgo,$(VER_MAJOR).$(VER_MINOR)-cgo,$(VER_MAJOR)-cgo" > .tags
docker: deps
@docker build -f ./resources/docker/Dockerfile . -t jeffail/benthos:$(VER_CUT)
@docker tag jeffail/benthos:$(VER_CUT) jeffail/benthos:latest
docker-cgo: deps
@docker build -f ./resources/docker/Dockerfile.cgo . -t jeffail/benthos:$(VER_CUT)-cgo
@docker tag jeffail/benthos:$(VER_CUT)-cgo jeffail/benthos:latest-cgo
fmt:
@go list -f {{.Dir}} ./... | xargs -I{} gofmt -w -s {}
lint:
@go vet $(GO_FLAGS) ./...
@golint -min_confidence 0.5 ./cmd/... ./lib/...
test:
@go test $(GO_FLAGS) -timeout 300s -short ./...
test-race:
@go test $(GO_FLAGS) -timeout 300s -short -race ./...
test-integration:
@go test $(GO_FLAGS) -timeout 600s ./...
clean:
rm -rf $(PATHINSTBIN)
rm -rf $(DEST_DIR)/dist
rm -rf $(DEST_DIR)/serverless
rm -rf $(PATHINSTDOCKER)
docs: $(APPS)
@$(PATHINSTBIN)/benthos --list-inputs > ./docs/inputs/README.md; true
@$(PATHINSTBIN)/benthos --list-processors > ./docs/processors/README.md; true
@$(PATHINSTBIN)/benthos --list-conditions > ./docs/conditions/README.md; true
@$(PATHINSTBIN)/benthos --list-buffers > ./docs/buffers/README.md; true
@$(PATHINSTBIN)/benthos --list-outputs > ./docs/outputs/README.md; true
@$(PATHINSTBIN)/benthos --list-caches > ./docs/caches/README.md; true
@$(PATHINSTBIN)/benthos --list-rate-limits > ./docs/rate_limits/README.md; true
@$(PATHINSTBIN)/benthos --list-metrics > ./docs/metrics/README.md; true
@$(PATHINSTBIN)/benthos --list-tracers > ./docs/tracers/README.md; true
@go run $(GO_FLAGS) ./cmd/tools/benthos_config_gen/main.go
deploy-docs:
@git diff-index --quiet HEAD -- || ( echo "Failed: Branch must be clean"; false )
@mkdocs build -f ./.mkdocs.yml
@git fetch origin gh-pages
@git checkout gh-pages ./archive
@git reset HEAD
@mv ./archive ./site/
@git checkout gh-pages
@ls -1 | grep -v "site" | xargs rm -rf
@mv site/* .
@rmdir ./site
@git add -A
@git commit -m 'Deployed ${VERSION} with MkDocs'
@git push origin gh-pages
@git checkout master