From 9833716ce58a3693cf75fd02451f149c5b51d41b Mon Sep 17 00:00:00 2001 From: dd di cesare Date: Wed, 29 May 2024 21:24:07 +0200 Subject: [PATCH] [make] Packaging, uploading and sync Signed-off-by: dd di cesare --- Makefile | 1 + make/helm.mk | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 59b97c41..e6861fcc 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ REGISTRY = quay.io # Organization in container resgistry ORG ?= kuadrant +REPO_NAME ?= limitador-operator # kubebuilder-tools still doesn't support darwin/arm64. This is a workaround (https://github.com/kubernetes-sigs/controller-runtime/issues/1657) ARCH_PARAM = diff --git a/make/helm.mk b/make/helm.mk index 4c5f11d9..3248f870 100644 --- a/make/helm.mk +++ b/make/helm.mk @@ -1,7 +1,7 @@ ##@ Helm Charts .PHONY: helm-build -helm-build: ## Build the helm chart from kustomize manifests +helm-build: $(KUSTOMIZE) $(OPERATOR_SDK) $(YQ) manifests ## Build the helm chart from kustomize manifests # Generate kustomize manifests out of code notations $(OPERATOR_SDK) generate kustomize manifests -q # Set desired operator image and related limitador image @@ -25,3 +25,43 @@ helm-uninstall: $(HELM) ## Uninstall the helm chart helm-upgrade: $(HELM) ## Upgrade the helm chart # Upgrade the helm chart in the cluster $(HELM) upgrade limitador-operator charts/limitador-operator + +.PHONY: helm-package +helm-package: $(HELM) ## Package the helm chart + # Package the helm chart + $(HELM) package charts/limitador-operator + +# GitHub Token with permissions to upload to the release assets +GITHUB_TOKEN ?= +# GitHub Release ID, to find the release_id query the GET /repos/{owner}/{repo}/releases/latest or GET /repos/{owner}/{repo}/releases endpoints +RELEASE_ID ?= +# GitHub Release Asset ID, it can be find in the output of the uploaded asset +ASSET_ID ?= +# GitHub Release Asset Browser Download URL, it can be find in the output of the uploaded asset +BROWSER_DOWNLOAD_URL ?= +ifeq (0.0.0,$(VERSION)) +CHART_VERSION = $(VERSION)-dev +else +CHART_VERSION = $(VERSION) +endif + +.PHONY: helm-upload-package +helm-upload-package: $(HELM) ## Upload the helm chart package to the GitHub release assets + curl -L -s \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $(GITHUB_TOKEN)" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -H "Content-Type: application/octet-stream" \ + "https://uploads.github.com/repos/$(ORG)/$(REPO_NAME)/releases/$(RELEASE_ID)/assets?name=chart-limitador-operator-$(CHART_VERSION).tgz" \ + --data-binary "@limitador-operator-$(CHART_VERSION).tgz" + +.PHONY: helm-sync-package +helm-sync-package: $(HELM) ## Sync the helm chart package to the helm-charts repo + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $(GITHUB_TOKEN)" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/$(ORG)/$(REPO_NAME)/dispatches \ + -d '{"event_type":"sync-chart","client_payload":{"chart":limitador-operator,"version":"$(CHART_VERSION)", "asset_id":"$(ASSET_ID)", "browser_download_url": "$(BROWSER_DOWNLOAD_URL)"}}'