From 523dc75fecf981e7b04b44682f9dc9a173d52c58 Mon Sep 17 00:00:00 2001 From: Allen Conlon Date: Tue, 18 Mar 2025 21:00:19 -0400 Subject: [PATCH 1/3] ci: publish helm charts to oci repos Signed-off-by: Allen Conlon (cherry picked from commit fa2e499727ba43f0e2b559e74d5bd68910037b98) --- .github/workflows/build.yml | 2 +- .github/workflows/helm-lint.yaml | 2 +- Makefile | 1 - build/crds/build-crds.sh | 2 +- build/makelib/golang.mk | 2 +- build/makelib/helm.mk | 2 +- build/rbac/keep-added.sh | 2 +- build/rbac/keep-rbac-yaml.sh | 2 +- build/release/Makefile | 19 ++++++++++++++++++- 9 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 069a8ff30..3972b5838 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: - name: Set up Helm uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0 with: - version: v3.6.2 + version: v3.17.1 - name: build rook run: | diff --git a/.github/workflows/helm-lint.yaml b/.github/workflows/helm-lint.yaml index b274a0103..6f8112796 100644 --- a/.github/workflows/helm-lint.yaml +++ b/.github/workflows/helm-lint.yaml @@ -33,7 +33,7 @@ jobs: - name: Set up Helm uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0 with: - version: v3.6.2 + version: v3.17.1 - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 with: diff --git a/Makefile b/Makefile index 413f33f61..fd7ab2545 100644 --- a/Makefile +++ b/Makefile @@ -190,7 +190,6 @@ gen-rbac: $(HELM) $(YQ) ## Generate RBAC from Helm charts @# output only stdout to the file; stderr for debugging should keep going to stderr HELM=$(HELM) ./build/rbac/gen-common.sh HELM=$(HELM) ./build/rbac/gen-nfs-rbac.sh - HELM=$(HELM) ./build/rbac/gen-psp.sh gen.docs: docs docs: helm-docs diff --git a/build/crds/build-crds.sh b/build/crds/build-crds.sh index c88adb3b0..09a8143db 100755 --- a/build/crds/build-crds.sh +++ b/build/crds/build-crds.sh @@ -36,7 +36,7 @@ OLM_CATALOG_DIR="${DESTINATION_ROOT}/deploy/olm/deploy/crds" CEPH_CRDS_FILE_PATH="${DESTINATION_ROOT}/deploy/examples/crds.yaml" CEPH_HELM_CRDS_FILE_PATH="${DESTINATION_ROOT}/deploy/charts/rook-ceph/templates/resources.yaml" -if [[ "$($YQ_BIN_PATH --version)" != "yq (https://github.com/mikefarah/yq/) version 4."* ]]; then +if [[ "$($YQ_BIN_PATH --version)" != "yq (https://github.com/mikefarah/yq/) version v4."* ]]; then echo "yq must be version 4.x" exit 1 fi diff --git a/build/makelib/golang.mk b/build/makelib/golang.mk index ec820e1f9..01ed6e09a 100644 --- a/build/makelib/golang.mk +++ b/build/makelib/golang.mk @@ -222,7 +222,7 @@ $(CONTROLLER_GEN): rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ } -YQ_VERSION = v4.14.2 +YQ_VERSION = v4.45.1 YQ := $(TOOLS_HOST_DIR)/yq-$(YQ_VERSION) export YQ $(YQ): diff --git a/build/makelib/helm.mk b/build/makelib/helm.mk index 2bb970c8e..bd1d666c0 100644 --- a/build/makelib/helm.mk +++ b/build/makelib/helm.mk @@ -20,7 +20,7 @@ HELM_CHARTS_DIR ?= $(ROOT_DIR)/deploy/charts HELM_OUTPUT_DIR ?= $(OUTPUT_DIR)/charts HELM_HOME := $(abspath $(CACHE_DIR)/helm) -HELM_VERSION := v3.6.2 +HELM_VERSION := v3.17.1 HELM := $(TOOLS_HOST_DIR)/helm-$(HELM_VERSION) HELM_INDEX := $(HELM_OUTPUT_DIR)/index.yaml export HELM_HOME diff --git a/build/rbac/keep-added.sh b/build/rbac/keep-added.sh index 13ff3669a..96aa978c0 100755 --- a/build/rbac/keep-added.sh +++ b/build/rbac/keep-added.sh @@ -9,7 +9,7 @@ KEEP_FILE="$2" : ${YQ:=yq} -if [[ "$($YQ --version)" != "yq (https://github.com/mikefarah/yq/) version 4."* ]]; then +if [[ "$($YQ --version)" != "yq (https://github.com/mikefarah/yq/) version v4."* ]]; then echo "yq must be version 4.x" exit 1 fi diff --git a/build/rbac/keep-rbac-yaml.sh b/build/rbac/keep-rbac-yaml.sh index d8189a0ab..04f5803c5 100755 --- a/build/rbac/keep-rbac-yaml.sh +++ b/build/rbac/keep-rbac-yaml.sh @@ -7,7 +7,7 @@ set -eEuo pipefail : ${YQ:=yq} -if [[ "$($YQ --version)" != "yq (https://github.com/mikefarah/yq/) version 4."* ]]; then +if [[ "$($YQ --version)" != "yq (https://github.com/mikefarah/yq/) version v4."* ]]; then echo "yq must be version 4.x" exit 1 fi diff --git a/build/release/Makefile b/build/release/Makefile index efb068736..74a6f5a17 100644 --- a/build/release/Makefile +++ b/build/release/Makefile @@ -59,8 +59,10 @@ REMOTE_NAME ?= origin PLATFORMS ?= $(ALL_PLATFORMS) +# "helm" flavor is for pushing to s3/https endpoint +# "charts" flavor is for pushing to oci endpoint ifneq ($(filter master release-%,$(BRANCH_NAME)),) -FLAVORS ?= output images docs helm +FLAVORS ?= output images docs helm charts else FLAVORS ?= output override BRANCH_NAME := pr/$(BRANCH_NAME) @@ -156,6 +158,17 @@ promote.helm: $(HELM) $(S3_SYNC_DEL) $(HELM_TEMP) s3://$(HELM_S3_BUCKET)/$(CHANNEL) rm -fr $(HELM_TEMP) +define chart.targets +promote.chart.$(1).$(2): + @echo === helm push $(2) to $(1) + $(HELM) push $(HELM_OUTPUT_DIR)/$(2)-$(VERSION).tgz oci://$(1) +promote.all.charts: promote.chart.$(1).$(2) +clean.chart.$(1).$(2): + @rm -fr $(HELM_OUTPUT_DIR)/$(2)-$(VERSION).tgz +clean.all.charts: clean.chart.$(1).$(2) +endef +$(foreach r,$(REGISTRIES), $(foreach c,$(HELM_CHARTS),$(eval $(call chart.targets,$(r),$(c))))) + # ==================================================================================== # output @@ -207,6 +220,10 @@ publish.images: $(addprefix publish.manifest.image.,$(IMAGES)) promote.images: $(addprefix promote.manifest.image.,$(IMAGES)) clean.images: clean.all.images +build.charts: build.all.charts +promote.charts: promote.all.charts +clean.charts: clean.all.charts + # ==================================================================================== # Help From fe08a33abcc24ae0bb0714db7ac5e60601425c27 Mon Sep 17 00:00:00 2001 From: Allen Conlon Date: Mon, 24 Mar 2025 18:40:01 -0400 Subject: [PATCH 2/3] ci: fix version of chart not existing Signed-off-by: Allen Conlon (cherry picked from commit 2cbcbffd528cce9e9439984215b69c9782a2efa3) --- build/release/Makefile | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/build/release/Makefile b/build/release/Makefile index 74a6f5a17..fde3fab32 100644 --- a/build/release/Makefile +++ b/build/release/Makefile @@ -158,14 +158,36 @@ promote.helm: $(HELM) $(S3_SYNC_DEL) $(HELM_TEMP) s3://$(HELM_S3_BUCKET)/$(CHANNEL) rm -fr $(HELM_TEMP) +# set the helm cart version number. +# you should not need to do this for the majority of scenarios. +ifeq ($(origin HELM_CHART_VERSION), undefined) +# this changes the third '.' to a '-': +# example v1.16.0.371.g4aec70601 -> v1.16.0-371.g4aec70601 +# as helm has strict rules on allowable versions to comply with SemVer2 +HELM_CHART_VERSION := $(shell echo "$(VERSION)" | sed 's/\./-/3' ) +endif +export HELM_CHART_VERSION + +# we need to re-package the charts with the HELM_CHART_VERSION, +# as there is a difference with the helm charts that was +# created during the release scripts +define chart.build +build.chart.$(1): + @echo === helm package $(1) + mkdir -p $(HELM_OUTPUT_DIR) + $(HELM) package --version $(HELM_CHART_VERSION) --app-version $(VERSION) $(HELM_CHARTS_DIR)/$(1) --destination $(HELM_OUTPUT_DIR) +build.all.charts: build.chart.$(1) +clean.chart.$(1): + @rm -fr $(HELM_OUTPUT_DIR)/$(1)-$(HELM_CHART_VERSION).tgz +clean.all.charts: clean.chart.$(1) +endef +$(foreach c,$(HELM_CHARTS),$(eval $(call chart.build,$(c)))) + define chart.targets promote.chart.$(1).$(2): @echo === helm push $(2) to $(1) $(HELM) push $(HELM_OUTPUT_DIR)/$(2)-$(VERSION).tgz oci://$(1) promote.all.charts: promote.chart.$(1).$(2) -clean.chart.$(1).$(2): - @rm -fr $(HELM_OUTPUT_DIR)/$(2)-$(VERSION).tgz -clean.all.charts: clean.chart.$(1).$(2) endef $(foreach r,$(REGISTRIES), $(foreach c,$(HELM_CHARTS),$(eval $(call chart.targets,$(r),$(c))))) From 027fd55165d3cfd5888628e2b2d4bef8be93fb53 Mon Sep 17 00:00:00 2001 From: Allen Conlon Date: Tue, 25 Mar 2025 17:03:29 -0400 Subject: [PATCH 3/3] ci: fix push version mismatch Signed-off-by: Allen Conlon (cherry picked from commit 1291045c7f96ebf3d382b485749c8cafafa94b65) --- build/release/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/release/Makefile b/build/release/Makefile index fde3fab32..83f4d3c2d 100644 --- a/build/release/Makefile +++ b/build/release/Makefile @@ -186,7 +186,7 @@ $(foreach c,$(HELM_CHARTS),$(eval $(call chart.build,$(c)))) define chart.targets promote.chart.$(1).$(2): @echo === helm push $(2) to $(1) - $(HELM) push $(HELM_OUTPUT_DIR)/$(2)-$(VERSION).tgz oci://$(1) + $(HELM) push $(HELM_OUTPUT_DIR)/$(2)-$(HELM_CHART_VERSION).tgz oci://$(1) promote.all.charts: promote.chart.$(1).$(2) endef $(foreach r,$(REGISTRIES), $(foreach c,$(HELM_CHARTS),$(eval $(call chart.targets,$(r),$(c)))))