Skip to content

Commit badc7ff

Browse files
committed
Build tarballs for each OS introduce SHA-512
1 parent 04e2b5f commit badc7ff

File tree

2 files changed

+37
-38
lines changed

2 files changed

+37
-38
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/bin/
22
/test/bin/
3-
/*.tar.gz
3+
/*.tar.gz*
44
ci.env
55
pr.env
66
junit*.xml
77
debug.test
8+
/output/

Makefile

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414

1515
# Build the node-problem-detector image.
1616

17-
.PHONY: all build-container build-tar build push-container push-tar push \
18-
clean vet fmt version \
19-
Dockerfile build-binaries docker-builder build-in-docker
17+
.PHONY: all \
18+
vet fmt version test e2e-test \
19+
build-binaries build-container build-tar build \
20+
docker-builder build-in-docker push-container push-tar push clean
2021

2122
all: build
2223

24+
# PLATFORMS is the set of OS_ARCH that NPD can build against.
25+
PLATFORMS=linux_amd64 windows_amd64
26+
2327
# VERSION is the version of the binary.
2428
VERSION?=$(shell if [ -d .git ]; then echo `git describe --tags --dirty`; else echo "UNKNOWN"; fi)
2529

@@ -48,8 +52,9 @@ endif
4852
# PARALLEL specifies the number of parallel test nodes to run for e2e tests.
4953
PARALLEL?=3
5054

55+
NPD_NAME_VERSION?=node-problem-detector-$(VERSION)
5156
# TARBALL is the name of release tar. Include binary version by default.
52-
TARBALL?=node-problem-detector-$(VERSION).tar.gz
57+
TARBALL=$(NPD_NAME_VERSION).tar.gz
5358

5459
# IMAGE is the image name of the node problem detector container image.
5560
IMAGE:=$(REGISTRY)/node-problem-detector:$(TAG)
@@ -87,7 +92,7 @@ endif
8792

8893
ifeq ($(ENABLE_JOURNALD), 1)
8994
# Enable journald build tag.
90-
LINUX_BUILD_TAGS := $(BUILD_TAGS) journald
95+
LINUX_BUILD_TAGS := journald $(BUILD_TAGS)
9196
# Enable cgo because sdjournal needs cgo to compile. The binary will be
9297
# dynamically linked if CGO_ENABLED is enabled. This is fine because fedora
9398
# already has necessary dynamic library. We can not use `-extldflags "-static"`
@@ -112,23 +117,16 @@ fmt:
112117
version:
113118
@echo $(VERSION)
114119

115-
WINDOWS_AMD64_BINARIES = bin/windows_amd64/node-problem-detector.exe bin/windows_amd64/health-checker.exe
116-
WINDOWS_AMD64_TEST_BINARIES = test/bin/windows_amd64/problem-maker.exe
117-
LINUX_AMD64_BINARIES = bin/linux_amd64/node-problem-detector bin/linux_amd64/health-checker
118-
LINUX_AMD64_TEST_BINARIES = test/bin/linux_amd64/problem-maker
120+
BINARIES = bin/node-problem-detector bin/health-checker test/bin/problem-maker
121+
BINARIES_LINUX_ONLY =
119122
ifeq ($(ENABLE_JOURNALD), 1)
120-
LINUX_AMD64_BINARIES += bin/linux_amd64/log-counter
123+
BINARIES_LINUX_ONLY += bin/log-counter
121124
endif
122125

123-
WINDOWS_BINARIES = $(WINDOWS_AMD64_BINARIES) $(WINDOWS_AMD64_TEST_BINARIES)
124-
LINUX_BINARIES = $(LINUX_AMD64_BINARIES) $(LINUX_AMD64_TEST_BINARIES)
125-
126-
windows-binaries: $(WINDOWS_BINARIES)
126+
ALL_BINARIES = $(foreach binary, $(BINARIES) $(BINARIES_LINUX_ONLY), ./$(binary)) $(foreach binary, $(BINARIES) $(BINARIES_LINUX_ONLY), output/linux_amd64/$(binary)) $(foreach binary, $(BINARIES), output/windows_amd64/$(binary).exe)
127+
ALL_TARBALLS = $(foreach platform, $(PLATFORMS), $(NPD_NAME_VERSION)-$(platform).tar.gz)
127128

128-
bin/windows_amd64/%.exe: $(PKG_SOURCES)
129-
ifeq ($(ENABLE_JOURNALD), 1)
130-
echo "Journald on Windows is not supported, use make ENABLE_JOURNALD=0 [TARGET]"
131-
endif
129+
output/windows_amd64/bin/%.exe: $(PKG_SOURCES)
132130
GOOS=windows GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \
133131
-mod vendor \
134132
-o $@ \
@@ -137,17 +135,14 @@ endif
137135
./cmd/$(subst -,,$*)
138136
touch $@
139137

140-
./test/bin/windows_amd64/%.exe: $(PKG_SOURCES)
141-
ifeq ($(ENABLE_JOURNALD), 1)
142-
echo "Journald on Windows is not supported, use make ENABLE_JOURNALD=0 [TARGET]"
143-
endif
138+
output/windows_amd64/test/bin/%.exe: $(PKG_SOURCES)
144139
GOOS=windows GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \
145140
-mod vendor \
146141
-o $@ \
147142
-tags "$(WINDOWS_BUILD_TAGS)" \
148143
./test/e2e/$(subst -,,$*)
149144

150-
bin/linux_amd64/%: $(PKG_SOURCES)
145+
output/linux_amd64/bin/%: $(PKG_SOURCES)
151146
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \
152147
-mod vendor \
153148
-o $@ \
@@ -156,18 +151,13 @@ bin/linux_amd64/%: $(PKG_SOURCES)
156151
./cmd/$(subst -,,$*)
157152
touch $@
158153

159-
./test/bin/linux_amd64/%: $(PKG_SOURCES)
154+
output/linux_amd64/test/bin/%: $(PKG_SOURCES)
160155
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \
161156
-mod vendor \
162157
-o $@ \
163158
-tags "$(LINUX_BUILD_TAGS)" \
164159
./test/e2e/$(subst -,,$*)
165160

166-
ifneq ($(ENABLE_JOURNALD), 1)
167-
bin/linux_amd64/log-counter:
168-
echo "Warning: log-counter requires journald, skipping."
169-
endif
170-
171161
# In the future these targets should be deprecated.
172162
./bin/log-counter: $(PKG_SOURCES)
173163
ifeq ($(ENABLE_JOURNALD), 1)
@@ -217,16 +207,25 @@ e2e-test: vet fmt build-tar
217207
-boskos-project-type=$(BOSKOS_PROJECT_TYPE) -job-name=$(JOB_NAME) \
218208
-artifacts-dir=$(ARTIFACTS)
219209

220-
build-binaries: ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker $(WINDOWS_BINARIES) $(LINUX_BINARIES)
210+
$(NPD_NAME_VERSION)-%.tar.gz: $(ALL_BINARIES) test/e2e-install.sh
211+
mkdir -p output/$*/ output/$*/test/
212+
cp -r config/ output/$*/
213+
cp test/e2e-install.sh output/$*/test/e2e-install.sh
214+
(cd output/$*/ && tar -zcvf ../../$@ *)
215+
sha512sum $@ > $@.sha512
216+
217+
build-binaries: $(ALL_BINARIES)
221218

222219
build-container: build-binaries Dockerfile
223220
docker build -t $(IMAGE) --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg LOGCOUNTER=$(LOGCOUNTER) .
224221

225-
build-tar: ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker ./test/bin/problem-maker
222+
$(TARBALL): ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker ./test/bin/problem-maker
226223
tar -zcvf $(TARBALL) bin/ config/ test/e2e-install.sh test/bin/problem-maker
227224
sha1sum $(TARBALL)
228225
md5sum $(TARBALL)
229226

227+
build-tar: $(TARBALL) $(ALL_TARBALLS)
228+
230229
build: build-container build-tar
231230

232231
docker-builder:
@@ -243,13 +242,12 @@ push-container: build-container
243242

244243
push-tar: build-tar
245244
gsutil cp $(TARBALL) $(UPLOAD_PATH)/node-problem-detector/
245+
gsutil cp node-problem-detector-$(VERSION)-*.tar.gz* $(UPLOAD_PATH)/node-problem-detector/
246246

247247
push: push-container push-tar
248248

249249
clean:
250-
rm -f bin/health-checker
251-
rm -f bin/log-counter
252-
rm -f bin/node-problem-detector
253-
rm -f $(WINDOWS_AMD64_BINARIES) $(LINUX_AMD64_BINARIES)
254-
rm -f test/bin/problem-maker
255-
rm -f node-problem-detector-*.tar.gz
250+
rm -rf bin/
251+
rm -rf test/bin/
252+
rm -f node-problem-detector-*.tar.gz*
253+
rm -rf output/

0 commit comments

Comments
 (0)