Skip to content

Commit

Permalink
Add Helm chart OCI release to GH automation
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Ramlot <[email protected]>
  • Loading branch information
inteon committed Dec 11, 2024
1 parent 9b27feb commit ca23d5a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 37 deletions.
25 changes: 5 additions & 20 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
VERSION: ${{ github.ref_name }}

jobs:
build_images:
build_and_push:
runs-on: ubuntu-latest

permissions:
Expand Down Expand Up @@ -36,19 +36,13 @@ jobs:
- id: release
run: make release

- uses: actions/upload-artifact@v4
with:
name: ${{ steps.release.outputs.RELEASE_HELM_CHART_NAME }}-${{ steps.release.outputs.RELEASE_HELM_CHART_VERSION }}.tgz
path: ${{ steps.release.outputs.RELEASE_HELM_CHART_TAR }}
if-no-files-found: error

outputs:
RELEASE_OCI_MANAGER_IMAGE: ${{ steps.release.outputs.RELEASE_OCI_MANAGER_IMAGE }}
RELEASE_OCI_MANAGER_TAG: ${{ steps.release.outputs.RELEASE_OCI_MANAGER_TAG }}
RELEASE_OCI_PACKAGE_DEBIAN_IMAGE: ${{ steps.release.outputs.RELEASE_OCI_PACKAGE_DEBIAN_IMAGE }}
RELEASE_OCI_PACKAGE_DEBIAN_TAG: ${{ steps.release.outputs.RELEASE_OCI_PACKAGE_DEBIAN_TAG }}
RELEASE_HELM_CHART_NAME: ${{ steps.release.outputs.RELEASE_HELM_CHART_NAME }}
RELEASE_HELM_CHART_VERSION: ${{ steps.release.outputs.RELEASE_HELM_CHART_VERSION }}
RELEASE_HELM_CHART_IMAGE: ${{ steps.release.outputs.RELEASE_HELM_CHART_IMAGE }}
RELEASE_HELM_CHART_TAG: ${{ steps.release.outputs.RELEASE_HELM_CHART_TAG }}

github_release:
runs-on: ubuntu-latest
Expand All @@ -66,13 +60,8 @@ jobs:
echo "OCI_MANAGER_TAG: ${{ needs.build_images.outputs.RELEASE_OCI_MANAGER_TAG }}" >> .notes-file
echo "OCI_PACKAGE_DEBIAN_IMAGE: ${{ needs.build_images.outputs.RELEASE_OCI_PACKAGE_DEBIAN_IMAGE }}" >> .notes-file
echo "OCI_PACKAGE_DEBIAN_TAG: ${{ needs.build_images.outputs.RELEASE_OCI_PACKAGE_DEBIAN_TAG }}" >> .notes-file
echo "HELM_CHART_NAME: ${{ needs.build_images.outputs.RELEASE_HELM_CHART_NAME }}" >> .notes-file
echo "HELM_CHART_VERSION: ${{ needs.build_images.outputs.RELEASE_HELM_CHART_VERSION }}" >> .notes-file
- id: chart_download
uses: actions/download-artifact@v4
with:
name: ${{ needs.build_images.outputs.RELEASE_HELM_CHART_NAME }}-${{ needs.build_images.outputs.RELEASE_HELM_CHART_VERSION }}.tgz
echo "HELM_CHART_IMAGE: ${{ needs.build_images.outputs.RELEASE_HELM_CHART_IMAGE }}" >> .notes-file
echo "HELM_CHART_TAG: ${{ needs.build_images.outputs.RELEASE_HELM_CHART_TAG }}" >> .notes-file
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -83,7 +72,3 @@ jobs:
--draft \
--verify-tag \
--notes-file .notes-file
gh release upload "$VERSION" \
--repo="$GITHUB_REPOSITORY" \
"${{ steps.chart_download.outputs.download-path }}/${{ needs.build_images.outputs.RELEASE_HELM_CHART_NAME }}-${{ needs.build_images.outputs.RELEASE_HELM_CHART_VERSION }}.tgz"
2 changes: 1 addition & 1 deletion klone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ targets:
- folder_name: helm
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: 25ec11345ab139986fad5fe7ffb5503069e6f81b
repo_hash: fbd26411777b12c2574d05f146cee617c6c50b63
repo_path: modules/helm
- folder_name: help
repo_url: https://github.com/cert-manager/makefile-modules.git
Expand Down
5 changes: 1 addition & 4 deletions make/00_mod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ deploy_name := trust-manager
deploy_namespace := cert-manager

helm_chart_source_dir := deploy/charts/trust-manager
helm_chart_name := trust-manager
helm_chart_image_name := quay.io/jetstack/charts/trust-manager
helm_chart_version := $(VERSION)
helm_labels_template_name := trust-manager.labels
helm_docs_use_helm_tool := 1
helm_generate_schema := 1
helm_verify_values := 1

golangci_lint_config := .golangci.yaml

Expand Down
10 changes: 5 additions & 5 deletions make/02_mod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ include make/debian-trust-package.mk
.PHONY: release
## Publish all release artifacts (image + helm chart)
## @category [shared] Release
release: $(helm_chart_archive) | $(NEEDS_CRANE)
release:
$(MAKE) oci-push-manager
$(MAKE) oci-maybe-push-package_debian
$(MAKE) helm-chart-oci-push

@echo "RELEASE_OCI_MANAGER_IMAGE=$(oci_manager_image_name)" >> "$(GITHUB_OUTPUT)"
@echo "RELEASE_OCI_MANAGER_TAG=$(oci_manager_image_tag)" >> "$(GITHUB_OUTPUT)"
@echo "RELEASE_OCI_PACKAGE_DEBIAN_IMAGE=$(oci_package_debian_image_name)" >> "$(GITHUB_OUTPUT)"
@echo "RELEASE_OCI_PACKAGE_DEBIAN_TAG=$(oci_package_debian_image_tag)" >> "$(GITHUB_OUTPUT)"
@echo "RELEASE_HELM_CHART_NAME=$(helm_chart_name)" >> "$(GITHUB_OUTPUT)"
@echo "RELEASE_HELM_CHART_VERSION=$(helm_chart_version)" >> "$(GITHUB_OUTPUT)"
@echo "RELEASE_HELM_CHART_TAR=$(helm_chart_archive)" >> "$(GITHUB_OUTPUT)"
@echo "RELEASE_HELM_CHART_IMAGE=$(helm_chart_image_name)" >> "$(GITHUB_OUTPUT)"
@echo "RELEASE_HELM_CHART_TAG=$(helm_chart_image_tag)" >> "$(GITHUB_OUTPUT)"

@echo "Release complete!"

.PHONY: release-debian-trust-package
release-debian-trust-package: | $(NEEDS_CRANE)
release-debian-trust-package:
$(MAKE) oci-maybe-push-package_debian

@echo "RELEASE_OCI_PACKAGE_DEBIAN_IMAGE=$(oci_package_debian_image_name)" >> "$(GITHUB_OUTPUT)"
Expand Down
23 changes: 16 additions & 7 deletions make/_shared/helm/helm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ ifndef helm_chart_source_dir
$(error helm_chart_source_dir is not set)
endif

ifndef helm_chart_name
$(error helm_chart_name is not set)
ifndef helm_chart_image_name
$(error helm_chart_image_name is not set)
endif

ifndef helm_chart_version
$(error helm_chart_version is not set)
endif

ifndef helm_chart_app_version
# Default to the same as the chart version
helm_chart_app_version = $(helm_chart_version)
ifneq ($(helm_chart_version:v%=v),v)
$(error helm_chart_version "$(helm_chart_version)" should start with a "v")
endif

ifndef helm_values_mutation_function
Expand All @@ -43,6 +41,9 @@ endif

##########################################

helm_chart_name := $(notdir $(helm_chart_image_name))
helm_chart_image_registry := $(dir $(helm_chart_image_name))
helm_chart_image_tag := $(helm_chart_version)
helm_chart_sources := $(shell find $(helm_chart_source_dir) -maxdepth 1 -type f) $(shell find $(helm_chart_source_dir)/templates -type f)
helm_chart_archive := $(bin_dir)/scratch/image/$(helm_chart_name)-$(helm_chart_version).tgz

Expand All @@ -64,10 +65,18 @@ $(helm_chart_archive): $(helm_chart_sources) | $(NEEDS_HELM) $(NEEDS_YQ) $(bin_d

mkdir -p $(dir $@)
$(HELM) package $(helm_chart_source_dir_versioned) \
--app-version $(helm_chart_app_version) \
--app-version $(helm_chart_version) \
--version $(helm_chart_version) \
--destination $(dir $@)

.PHONY: helm-chart-oci-push
## Create and push Helm chart to OCI registry.
## Will also create a non-v-prefixed tag for the OCI image.
## @category [shared] Publish
helm-chart-oci-push: $(helm_chart_archive) | $(NEEDS_HELM) $(NEEDS_CRANE)
$(HELM) push "$(helm_chart_archive)" "oci://$(helm_chart_image_registry)"
$(CRANE) copy "$(helm_chart_image_name):$(helm_chart_image_tag)" "$(helm_chart_image_name):$(helm_chart_image_tag:v%=%)"

.PHONY: helm-chart
## Create a helm chart
## @category [shared] Helm Chart
Expand Down

0 comments on commit ca23d5a

Please sign in to comment.