-
Notifications
You must be signed in to change notification settings - Fork 29
/
Makefile
102 lines (82 loc) · 2.76 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
include cmd/Makefile
ACTION ?= --load
MACHINE := rancher
# Define the target platforms that can be used across the ecosystem.
# Note that what would actually be used for a given project will be
# defined in TARGET_PLATFORMS, and must be a subset of the below:
DEFAULT_PLATFORMS := linux/amd64,linux/arm64
BUILDX_ARGS ?= --sbom=true --attest type=provenance,mode=max
IMAGE := ecm-distro-tools
ifeq ($(TAG),)
TAG = $(shell git rev-parse HEAD)
endif
.PHONY: all
all: $(BINARIES)
.PHONY: gen_release_report
gen_release_report:
cd cmd/$@ && $(MAKE)
.PHONY: rancher_release
rancher_release:
cd cmd/$@ && $(MAKE)
.PHONY: rke2_release
rke2_release:
cd cmd/$@ && $(MAKE)
.PHONY: release
release:
cd cmd/$@ && $(MAKE)
.PHONY: backport
backport:
cd cmd/$@ && $(MAKE)
.PHONY: test_coverage
test_coverage:
cd cmd/$@ && $(MAKE)
.PHONY: upstream_go_version
upstream_go_version:
cd cmd/$@ && $(MAKE)
.PHONY: semv
semv:
cd cmd/$@ && $(MAKE)
.PHONY: test
test:
go test -v -cover ./...
.PHONY: buildx-machine
buildx-machine: ## create rancher dockerbuildx machine targeting platform defined by DEFAULT_PLATFORMS.
@docker buildx ls | grep $(MACHINE) || docker buildx create --name=$(MACHINE) --platform=$(DEFAULT_PLATFORMS)
.PHONY: build-image
build-image: buildx-machine
docker buildx build --builder=$(MACHINE) $(ACTION) -t rancher/ecm-distro-tools:$(TAG) .
.PHONY: push-image
push-image: buildx-machine ## build the container image targeting all platforms defined by TARGET_PLATFORMS and push to a registry.
docker buildx build -f Dockerfile \
--builder=$(MACHINE) $(IID_FILE_FLAG) $(BUILDX_ARGS) \
--platform=$(DEFAULT_PLATFORMS) -t $(REPO)/$(IMAGE):$(TAG) --push .
@echo "Pushed $(REPO)/$(IMAGE):$(TAG)"
.PHONY: test-image
test-image: buildx-machine ## build the container image for all target architecures.
# Instead of loading image, target all platforms, effectivelly testing
# the build for the target architectures.
$(MAKE) build-image ACTION="--platform=$(DEFAULT_PLATFORMS)"
.PHONY: package-binaries
package-binaries: $(BINARIES)
mkdir -p dist
@$(eval export BIN_FILES = $(shell ls bin/))
for binary in $(BINARIES); do \
mv cmd/$${binary}/bin/sha256sums-$${binary}.txt dist/sha256sums-$${binary}.txt; \
done
cp bin/* dist/
for arch in $(ARCHS); do \
for os in $(OSs); do \
SUFFIX=$${os}-$${arch}; \
cd bin && \
tar cvf ../dist/ecm-distro-tools.$${SUFFIX}.tar $(BIN_FILES); \
cd ..; \
for binary in $(BINARIES); do \
mv cmd/$${binary}/bin/$${binary}-$${SUFFIX} dist/$${binary}-$${SUFFIX} && \
cd dist && \
tar rvf ecm-distro-tools.$${SUFFIX}.tar $${binary}-$${SUFFIX}; \
cd ..; \
done; \
gzip < dist/ecm-distro-tools.$${SUFFIX}.tar > dist/ecm-distro-tools.$${SUFFIX}.tar.gz && \
rm -f dist/ecm-distro-tools.$${SUFFIX}.tar; \
done; \
done