-
Notifications
You must be signed in to change notification settings - Fork 161
/
Makefile
95 lines (80 loc) · 2.88 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
GO ?= go
GORELEASER ?= goreleaser
OTELCOL_BUILDER_VERSION ?= 0.113.0
OTELCOL_BUILDER_DIR ?= ${HOME}/bin
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb
DISTRIBUTIONS ?= "otelcol,otelcol-contrib,otelcol-k8s,otelcol-otlp"
ci: check build
check: ensure-goreleaser-up-to-date
build: go ocb
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER}
generate: generate-sources generate-goreleaser
generate-goreleaser: go
@./scripts/generate-goreleaser.sh -d "${DISTRIBUTIONS}" -g ${GO}
generate-sources: go ocb
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER}
goreleaser-verify: goreleaser
@${GORELEASER} release --snapshot --clean
ensure-goreleaser-up-to-date: generate-goreleaser
@git diff -s --exit-code distributions/*/.goreleaser.yaml || (echo "Check failed: The goreleaser templates have changed but the .goreleaser.yamls haven't. Run 'make generate-goreleaser' and update your PR." && exit 1)
.PHONY: ocb
ocb:
ifeq (, $(shell command -v ocb 2>/dev/null))
@{ \
[ ! -x '$(OTELCOL_BUILDER)' ] || exit 0; \
set -e ;\
os=$$(uname | tr A-Z a-z) ;\
machine=$$(uname -m) ;\
[ "$${machine}" != x86 ] || machine=386 ;\
[ "$${machine}" != x86_64 ] || machine=amd64 ;\
echo "Installing ocb ($${os}/$${machine}) at $(OTELCOL_BUILDER_DIR)";\
mkdir -p $(OTELCOL_BUILDER_DIR) ;\
CGO_ENABLED=0 go install -trimpath -ldflags="-s -w" go.opentelemetry.io/collector/cmd/builder@v$(OTELCOL_BUILDER_VERSION) ;\
mv $$(go env GOPATH)/bin/builder $(OTELCOL_BUILDER) ;\
}
else
OTELCOL_BUILDER=$(shell command -v ocb)
endif
.PHONY: go
go:
@{ \
if ! command -v '$(GO)' >/dev/null 2>/dev/null; then \
echo >&2 '$(GO) command not found. Please install golang. https://go.dev/doc/install'; \
exit 1; \
fi \
}
.PHONY: goreleaser
goreleaser:
@{ \
if ! command -v '$(GORELEASER)' >/dev/null 2>/dev/null; then \
echo >&2 '$(GORELEASER) command not found. Please install goreleaser. https://goreleaser.com/install/'; \
exit 1; \
fi \
}
[email protected]:open-telemetry/opentelemetry-collector-releases.git
.PHONY: push-tags
push-tags:
@[ "${TAG}" ] || ( echo ">> env var TAG is not set"; exit 1 )
@echo "Adding tag ${TAG}"
@git tag -a ${TAG} -s -m "Version ${TAG}"
@echo "Pushing tag ${TAG}"
@git push ${REMOTE} ${TAG}
# Used for debug only
[email protected]:open-telemetry/opentelemetry-collector-releases.git
.PHONY: delete-tags
delete-tags:
@[ "${TAG}" ] || ( echo ">> env var TAG is not set"; exit 1 )
@echo "Deleting local tag ${TAG}"
@if [ -n "$$(git tag -l ${TAG})" ]; then \
git tag -d ${TAG}; \
fi
@if [ -n "$$(git tag -l cmd/builder/${TAG})" ]; then \
git tag -d cmd/builder/${TAG}; \
fi
@echo "Deleting remote tag ${TAG}"
@git push ${REMOTE} :refs/tags/${TAG}
@git push ${REMOTE} :refs/tags/cmd/builder/${TAG}
# Used for debug only
[email protected]:open-telemetry/opentelemetry-collector-releases.git
.PHONY: repeat-tags
repeat-tags: delete-tags push-tags