Skip to content

Commit

Permalink
[make] Packaging, uploading and sync
Browse files Browse the repository at this point in the history
Signed-off-by: dd di cesare <[email protected]>
  • Loading branch information
didierofrivia committed May 31, 2024
1 parent 8fd1924 commit 9833716
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
42 changes: 41 additions & 1 deletion make/helm.mk
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 ?= <YOUR-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 ?= <RELEASE-ID>
# GitHub Release Asset ID, it can be find in the output of the uploaded asset
ASSET_ID ?= <ASSET-ID>
# GitHub Release Asset Browser Download URL, it can be find in the output of the uploaded asset
BROWSER_DOWNLOAD_URL ?= <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)"}}'

0 comments on commit 9833716

Please sign in to comment.