@@ -16,31 +16,44 @@ TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(shell echo $(TOOLS_
1616GO_LICENCE_DETECTOR := $(TOOLS_BIN_DIR ) /go-licence-detector
1717GO_LICENCE_DETECTOR_CONFIG := $(SRC_ROOT ) /internal/assets/license/rules.json
1818
19- DISTRIBUTIONS ?= "nrdot-collector-host,nrdot-collector-k8s,nrdot-collector"
19+ DISTRO ?= nrdot-collector-host
20+ ALL_DISTROS = nrdot-collector-host nrdot-collector-k8s nrdot-collector
2021
21- ci : check build build-fips version-check licenses-check
22- check : ensure-goreleaser-up-to-date
22+ .PHONY : ci
23+ ci : pre-sourcegen-check- $( DISTRO ) generate-sources- $( DISTRO ) generate-sources- $( DISTRO ) -fips post-sourcegen-check- $( DISTRO )
2324
24- build : go ocb
25- @./scripts/build.sh -d " ${DISTRIBUTIONS} " -b ${OTELCOL_BUILDER}
25+ .PHONY : pre-sourcegen-check- $( DISTRO )
26+ pre-sourcegen-check- $( DISTRO ) : ensure-goreleaser-up-to-date- $( DISTRO ) version-check
2627
27- build-fips : go ocb
28- @./scripts/build.sh -d " ${DISTRIBUTIONS} " -b ${OTELCOL_BUILDER} -f true
28+ .PHONY : post-sourcegen-check- $( DISTRO )
29+ post-sourcegen-check- $( DISTRO ) : licenses-check- $( DISTRO )
2930
30- generate : generate-sources generate-goreleaser
31+ .PHONY : generate-sources-$(DISTRO )
32+ generate-sources-$(DISTRO ) : go ocb
33+ @./scripts/build.sh -d " $( DISTRO) " -b ${OTELCOL_BUILDER}
3134
32- generate-goreleaser : go
33- @./scripts/generate-goreleaser.sh -d " ${DISTRIBUTIONS} " -g ${GO}
35+ .PHONY : generate-sources-$(DISTRO ) -fips
36+ generate-sources-$(DISTRO ) -fips : go ocb
37+ @./scripts/build.sh -d " $( DISTRO) " -b ${OTELCOL_BUILDER} -f true
3438
35- generate-sources : go ocb
36- @./scripts/build.sh -d " ${DISTRIBUTIONS} " -s true -b ${OTELCOL_BUILDER}
39+ .PHONY : generate-goreleaser
40+ generate-goreleaser :
41+ @for d in $(ALL_DISTROS ) ; do \
42+ make generate-goreleaser-$$ d DISTRO=$$ d; \
43+ done
3744
38- goreleaser-verify : goreleaser
39- @${GORELEASER} release --snapshot --clean
45+ .PHONY : generate-goreleaser-$(DISTRO )
46+ generate-goreleaser-$(DISTRO ) : go
47+ @./scripts/generate-goreleaser.sh -d " $( DISTRO) " -g ${GO}
4048
41- ensure-goreleaser-up-to-date : generate-goreleaser
42- @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)
49+ .PHONY : ensure-goreleaser-up-to-date-$(DISTRO )
50+ ensure-goreleaser-up-to-date-$(DISTRO ) : generate-goreleaser-$(DISTRO )
51+ @{ \
52+ git diff -s --exit-code distributions/* /.goreleaser* .yaml || \
53+ (echo " 📋 Check failed: The goreleaser templates have changed but the .goreleaser.yamls haven't. Run 'make generate-goreleaser' and update your PR." && exit 1) \
54+ } && echo " 📋 Goreleaser files are up to date."
4355
56+ .PHONY : validate-components
4457validate-components :
4558 @./scripts/validate-components.sh
4659
@@ -148,17 +161,51 @@ $(TOOLS_BIN_NAMES): $(TOOLS_BIN_DIR) $(TOOLS_MOD_DIR)/go.mod
148161FILENAME? =$(shell git branch --show-current)
149162NOTICE_OUTPUT? =THIRD_PARTY_NOTICES.md
150163
151- .PHONY : licenses
152- licenses : go generate-sources $(GO_LICENCE_DETECTOR )
153- @./scripts/licenses.sh -d " ${DISTRIBUTIONS} " -b ${GO_LICENCE_DETECTOR} -n ${NOTICE_OUTPUT} -g ${GO}
154164
155- .PHONY : licenses-check
156- licenses-check : licenses
165+
166+ .PHONY : licenses
167+ licenses :
168+ @for d in $(ALL_DISTROS ) ; do \
169+ make licenses-$$ d DISTRO=$$ d; \
170+ done
171+
172+ .PHONY : licenses-$(DISTRO )
173+ licenses-$(DISTRO ) : go $(GO_LICENCE_DETECTOR )
174+ @{ if [ ! -d " distributions/$( DISTRO) /_build" ]; then $( MAKE) generate-sources-$( DISTRO) ; fi }
175+ @./scripts/licenses.sh -d " $( DISTRO) " -b ${GO_LICENCE_DETECTOR} -n ${NOTICE_OUTPUT} -g ${GO}
176+
177+ .PHONY : licenses-check-$(DISTRO )
178+ licenses-check-$(DISTRO ) : licenses-$(DISTRO )
157179 @git diff --name-only | grep -q $(NOTICE_OUTPUT ) \
158180 && { \
159- echo " Third party notices out of date, please run \" make licenses\" and commit the changes in this PR." ; \
181+ echo " 📜 Third party notices out of date, please run \" make licenses\" and commit the changes in this PR." ; \
160182 echo " Diff of $( NOTICE_OUTPUT) :" ; \
161183 git --no-pager diff HEAD -- * /$(NOTICE_OUTPUT ) ; \
162184 exit 1; \
163185 } \
164- || exit 0
186+ || { \
187+ echo " 📜 Third party notices up to date" ; \
188+ exit 0; \
189+ }
190+
191+
192+ .PHONY : clean
193+ clean : clean-build clean-dist clean-tools clean-act-tmp
194+
195+ .PHONY : clean-build
196+ clean-build :
197+ @rm -rf distributions/* /_build
198+ @rm -rf distributions/* /_build-fips
199+
200+ .PHONY : clean-dist
201+ clean-dist :
202+ @rm -rf distributions/* /dist
203+
204+ .PHONY : clean-tools
205+ clean-tools :
206+ @rm -rf .tools
207+
208+ .PHONY : clean-act-tmp
209+ clean-act-tmp :
210+ @rm -rf .artifacts
211+ @rm -rf .tmp
0 commit comments