kuma

Форк
0
/
distribution.mk 
108 строк · 5.0 Кб
1
DISTRIBUTION_LICENSE_PATH ?= tools/releases/templates
2
DISTRIBUTION_CONFIG_PATH ?= pkg/config/app/kuma-cp/kuma-cp.defaults.yaml
3
# A list of all distributions
4
# OS:ARCH:COREDNS:ENVOY_FLAVOUR
5
# COREDNS is always coredns(CORDNS_EXT)
6
# If you don't want to include just put skip
7
DISTRIBUTION_LIST ?= linux:amd64:coredns:envoy linux:arm64:coredns:envoy darwin:amd64:coredns:envoy darwin:arm64:coredns:envoy
8

9
PULP_HOST ?= "https://api.pulp.konnect-prod.konghq.com"
10
PULP_PACKAGE_TYPE ?= $(PROJECT_NAME)
11
PULP_RELEASE_IMAGE ?= kong/release-script
12
DISTRIBUTION_TARGET_NAME ?= $(PROJECT_NAME)-$(BUILD_INFO_VERSION)
13
PULP_DIST_VERSION ?= release
14
ifneq (,$(findstring preview,$(BUILD_INFO_VERSION)))
15
	PULP_DIST_VERSION=preview
16
endif
17
DISTRIBUTION_FOLDER=build/distributions/$(GOOS)-$(GOARCH)/$(DISTRIBUTION_TARGET_NAME)
18

19

20
# This function dynamically builds targets for building distribution packages and uploading them to pulp with a set of parameters
21
# $(1) - GOOS to build for
22
# $(2) - GOARCH to build for
23
# $(3) - coredns extension to use (or `skip` if we shouldn't include COREDNS)
24
# $(4) - primary envoy to use in the distribution (the binary that will be called `envoy`)
25
define make_distributions_target
26
build/distributions/$(1)-$(2)/$(DISTRIBUTION_TARGET_NAME): build/artifacts-$(1)-$(2)/kumactl build/artifacts-$(1)-$(2)/kuma-cp build/artifacts-$(1)-$(2)/kuma-dp
27
	rm -rf $$@
28
	mkdir -p $$@/bin $$@/conf
29
	cp build/artifacts-$(1)-$(2)/kumactl/kumactl $$@/bin
30
	cp build/artifacts-$(1)-$(2)/kuma-cp/kuma-cp $$@/bin
31
	cp build/artifacts-$(1)-$(2)/kuma-dp/kuma-dp $$@/bin
32
	cp $(DISTRIBUTION_LICENSE_PATH)/* $$@
33
	cp $(DISTRIBUTION_CONFIG_PATH) $$@/conf
34
# CoreDNS is not included when the value is `skip` otherwise it's used as the COREDNS_EXT (which is most commonly just coredns)
35
ifneq ($(3),skip)
36
	$(MAKE) build/artifacts-$(1)-$(2)/coredns COREDNS_EXT=$(subst coredns,,$(3))
37
	cp build/artifacts-$(1)-$(2)/coredns/coredns $$@/bin
38
endif
39

40
# Package envoy
41
	$(MAKE) build/artifacts-$(1)-$(2)/envoy ENVOY_EXT_$(1)_$(2)=$(subst envoy,,$(4))
42
	cp -r build/artifacts-$(1)-$(2)/envoy/* $$@/bin
43

44
	# Set permissions correctly
45
	find $$@ -type f | xargs chmod 555
46
	# Text files don't have executable access
47
	find $$@ -type f -exec grep -I -q '' {} \; -print | xargs chmod 444
48
# Rename all executables to `.exe` when building the windows distrib
49
ifeq ($(1),windows)
50
        # find on darwin doesn't support `-executable` so we use `-perm +111` which we can't use on Linux
51
	find $$@/bin $(if $(findstring Darwin,$(shell uname)),-perm +111,-executable) -type f -exec mv {} {}.exe \;
52
endif
53

54
build/distributions/out/$(DISTRIBUTION_TARGET_NAME)-$(1)-$(2).tar.gz: build/distributions/$(1)-$(2)/$(DISTRIBUTION_TARGET_NAME)
55
	mkdir -p build/distributions/out
56
	# Create a tar with group and owner 0 and mtime of 0 (this makes builds reproducible).
57
	# Have the tar be just the `kuma-version` folder and nothing else at root
58
	# tar is different between darwin and Linux so executre different commands
59
ifeq ($(shell uname),Darwin)
60
	tar --strip-components 3 --numeric-owner -czvf $$@ $$<
61
else
62
	tar --mtime='1970-01-01 00:00:00' -C $$(dir $$<) --sort=name --owner=root:0 --group=root:0 --numeric-owner -czvf $$@ $$(notdir $$<)
63
endif
64
	shasum -a 256 $$@ > $$@.sha256
65

66
.PHONY: publish/pulp/$(DISTRIBUTION_TARGET_NAME)-$(1)-$(2)
67
publish/pulp/$(DISTRIBUTION_TARGET_NAME)-$(1)-$(2):
68
	$$(call GATE_PUSH,docker run --rm \
69
		-e PULP_USERNAME="${PULP_USERNAME}" \
70
		-e PULP_PASSWORD="${PULP_PASSWORD}" \
71
		-e PULP_HOST=$(PULP_HOST) \
72
		-e CLOUDSMITH_API_KEY='$(CLOUDSMITH_API_KEY)' \
73
		-e CLOUDSMITH_DRY_RUN='' \
74
		-e IGNORE_CLOUDSMITH_FAILURES=x \
75
		-e USE_CLOUDSMITH=x \
76
		-e USE_PULP=x \
77
		-v $(TOP)/build/distributions/out:/files:ro \
78
		$(PULP_RELEASE_IMAGE) \
79
		release \
80
		--file=/files/$(DISTRIBUTION_TARGET_NAME)-$(1)-$(2).tar.gz \
81
		--package-type=$(PULP_PACKAGE_TYPE) \
82
		--dist-name=binaries \
83
		--dist-version=$(PULP_DIST_VERSION) \
84
		--publish)
85
endef
86

87
# These are meant to be used inside foreach
88
dist_os = $(word 1, $(subst :, ,$(elt)))
89
dist_arch = $(word 2, $(subst :, ,$(elt)))
90
dist_coredns = $(word 3, $(subst :, ,$(elt)))
91
dist_envoy = $(word 4, $(subst :, ,$(elt)))
92
dist_envoy_alt = $(word 5, $(subst :, ,$(elt)))
93
dist_name = $(dist_os)-$(dist_arch)
94
# Call make_distribution_target with each combination
95
$(foreach elt,$(DISTRIBUTION_LIST),$(eval $(call make_distributions_target,$(dist_os),$(dist_arch),$(dist_coredns),$(dist_envoy),$(dist_envoy_alt))))
96
ENABLED_DIST_NAMES=$(filter $(addprefix %,$(ENABLED_ARCH_OS)),$(foreach elt,$(DISTRIBUTION_LIST),$(dist_name)))
97

98
# Create a main target which will call the tar.gz target for each distribution
99
.PHONY: build/distributions ## Build tar.gz for each enabled distribution
100
build/distributions: $(patsubst %,build/distributions/out/$(DISTRIBUTION_TARGET_NAME)-%.tar.gz,$(ENABLED_DIST_NAMES))
101

102
# Create a main target which will publish to pulp each to the tar.gz built
103
.PHONY: publish/pulp ## Publish to pulp all enabled distributions
104
publish/pulp: $(addprefix publish/pulp/$(DISTRIBUTION_TARGET_NAME)-,$(ENABLED_DIST_NAMES))
105

106
.PHONY: clean/distributions
107
clean/distributions:
108
	rm -rf build/distributions
109

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.