Skip to content

Commit d685a48

Browse files
committed
Add Helm chart OCI release to GH automation
Signed-off-by: Tim Ramlot <[email protected]>
1 parent 9b27feb commit d685a48

File tree

6 files changed

+34
-43
lines changed

6 files changed

+34
-43
lines changed

.github/workflows/debian-trust-package-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- make/00_debian_version.mk
77

88
jobs:
9-
build_images:
9+
build_and_push:
1010
runs-on: ubuntu-latest
1111

1212
permissions:

.github/workflows/release.yaml

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ env:
88
VERSION: ${{ github.ref_name }}
99

1010
jobs:
11-
build_images:
11+
build_and_push:
1212
runs-on: ubuntu-latest
1313

1414
permissions:
@@ -36,24 +36,18 @@ jobs:
3636
- id: release
3737
run: make release
3838

39-
- uses: actions/upload-artifact@v4
40-
with:
41-
name: ${{ steps.release.outputs.RELEASE_HELM_CHART_NAME }}-${{ steps.release.outputs.RELEASE_HELM_CHART_VERSION }}.tgz
42-
path: ${{ steps.release.outputs.RELEASE_HELM_CHART_TAR }}
43-
if-no-files-found: error
44-
4539
outputs:
4640
RELEASE_OCI_MANAGER_IMAGE: ${{ steps.release.outputs.RELEASE_OCI_MANAGER_IMAGE }}
4741
RELEASE_OCI_MANAGER_TAG: ${{ steps.release.outputs.RELEASE_OCI_MANAGER_TAG }}
4842
RELEASE_OCI_PACKAGE_DEBIAN_IMAGE: ${{ steps.release.outputs.RELEASE_OCI_PACKAGE_DEBIAN_IMAGE }}
4943
RELEASE_OCI_PACKAGE_DEBIAN_TAG: ${{ steps.release.outputs.RELEASE_OCI_PACKAGE_DEBIAN_TAG }}
50-
RELEASE_HELM_CHART_NAME: ${{ steps.release.outputs.RELEASE_HELM_CHART_NAME }}
51-
RELEASE_HELM_CHART_VERSION: ${{ steps.release.outputs.RELEASE_HELM_CHART_VERSION }}
44+
RELEASE_HELM_CHART_IMAGE: ${{ steps.release.outputs.RELEASE_HELM_CHART_IMAGE }}
45+
RELEASE_HELM_CHART_TAG: ${{ steps.release.outputs.RELEASE_HELM_CHART_TAG }}
5246

5347
github_release:
5448
runs-on: ubuntu-latest
5549

56-
needs: build_images
50+
needs: build_and_push
5751

5852
permissions:
5953
contents: write # needed for creating a PR
@@ -62,17 +56,12 @@ jobs:
6256
steps:
6357
- run: |
6458
touch .notes-file
65-
echo "OCI_MANAGER_IMAGE: ${{ needs.build_images.outputs.RELEASE_OCI_MANAGER_IMAGE }}" >> .notes-file
66-
echo "OCI_MANAGER_TAG: ${{ needs.build_images.outputs.RELEASE_OCI_MANAGER_TAG }}" >> .notes-file
67-
echo "OCI_PACKAGE_DEBIAN_IMAGE: ${{ needs.build_images.outputs.RELEASE_OCI_PACKAGE_DEBIAN_IMAGE }}" >> .notes-file
68-
echo "OCI_PACKAGE_DEBIAN_TAG: ${{ needs.build_images.outputs.RELEASE_OCI_PACKAGE_DEBIAN_TAG }}" >> .notes-file
69-
echo "HELM_CHART_NAME: ${{ needs.build_images.outputs.RELEASE_HELM_CHART_NAME }}" >> .notes-file
70-
echo "HELM_CHART_VERSION: ${{ needs.build_images.outputs.RELEASE_HELM_CHART_VERSION }}" >> .notes-file
71-
72-
- id: chart_download
73-
uses: actions/download-artifact@v4
74-
with:
75-
name: ${{ needs.build_images.outputs.RELEASE_HELM_CHART_NAME }}-${{ needs.build_images.outputs.RELEASE_HELM_CHART_VERSION }}.tgz
59+
echo "OCI_MANAGER_IMAGE: ${{ needs.build_and_push.outputs.RELEASE_OCI_MANAGER_IMAGE }}" >> .notes-file
60+
echo "OCI_MANAGER_TAG: ${{ needs.build_and_push.outputs.RELEASE_OCI_MANAGER_TAG }}" >> .notes-file
61+
echo "OCI_PACKAGE_DEBIAN_IMAGE: ${{ needs.build_and_push.outputs.RELEASE_OCI_PACKAGE_DEBIAN_IMAGE }}" >> .notes-file
62+
echo "OCI_PACKAGE_DEBIAN_TAG: ${{ needs.build_and_push.outputs.RELEASE_OCI_PACKAGE_DEBIAN_TAG }}" >> .notes-file
63+
echo "HELM_CHART_IMAGE: ${{ needs.build_and_push.outputs.RELEASE_HELM_CHART_IMAGE }}" >> .notes-file
64+
echo "HELM_CHART_TAG: ${{ needs.build_and_push.outputs.RELEASE_HELM_CHART_TAG }}" >> .notes-file
7665
7766
- env:
7867
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -83,7 +72,3 @@ jobs:
8372
--draft \
8473
--verify-tag \
8574
--notes-file .notes-file
86-
87-
gh release upload "$VERSION" \
88-
--repo="$GITHUB_REPOSITORY" \
89-
"${{ steps.chart_download.outputs.download-path }}/${{ needs.build_images.outputs.RELEASE_HELM_CHART_NAME }}-${{ needs.build_images.outputs.RELEASE_HELM_CHART_VERSION }}.tgz"

klone.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ targets:
3535
- folder_name: helm
3636
repo_url: https://github.com/cert-manager/makefile-modules.git
3737
repo_ref: main
38-
repo_hash: 25ec11345ab139986fad5fe7ffb5503069e6f81b
38+
repo_hash: fbd26411777b12c2574d05f146cee617c6c50b63
3939
repo_path: modules/helm
4040
- folder_name: help
4141
repo_url: https://github.com/cert-manager/makefile-modules.git

make/00_mod.mk

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,9 @@ deploy_name := trust-manager
4343
deploy_namespace := cert-manager
4444

4545
helm_chart_source_dir := deploy/charts/trust-manager
46-
helm_chart_name := trust-manager
46+
helm_chart_image_name := quay.io/jetstack/charts/trust-manager
4747
helm_chart_version := $(VERSION)
4848
helm_labels_template_name := trust-manager.labels
49-
helm_docs_use_helm_tool := 1
50-
helm_generate_schema := 1
51-
helm_verify_values := 1
5249

5350
golangci_lint_config := .golangci.yaml
5451

make/02_mod.mk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ include make/debian-trust-package.mk
3737
.PHONY: release
3838
## Publish all release artifacts (image + helm chart)
3939
## @category [shared] Release
40-
release: $(helm_chart_archive) | $(NEEDS_CRANE)
40+
release:
4141
$(MAKE) oci-push-manager
4242
$(MAKE) oci-maybe-push-package_debian
43+
$(MAKE) helm-chart-oci-push
4344

4445
@echo "RELEASE_OCI_MANAGER_IMAGE=$(oci_manager_image_name)" >> "$(GITHUB_OUTPUT)"
4546
@echo "RELEASE_OCI_MANAGER_TAG=$(oci_manager_image_tag)" >> "$(GITHUB_OUTPUT)"
4647
@echo "RELEASE_OCI_PACKAGE_DEBIAN_IMAGE=$(oci_package_debian_image_name)" >> "$(GITHUB_OUTPUT)"
4748
@echo "RELEASE_OCI_PACKAGE_DEBIAN_TAG=$(oci_package_debian_image_tag)" >> "$(GITHUB_OUTPUT)"
48-
@echo "RELEASE_HELM_CHART_NAME=$(helm_chart_name)" >> "$(GITHUB_OUTPUT)"
49-
@echo "RELEASE_HELM_CHART_VERSION=$(helm_chart_version)" >> "$(GITHUB_OUTPUT)"
50-
@echo "RELEASE_HELM_CHART_TAR=$(helm_chart_archive)" >> "$(GITHUB_OUTPUT)"
49+
@echo "RELEASE_HELM_CHART_IMAGE=$(helm_chart_image_name)" >> "$(GITHUB_OUTPUT)"
50+
@echo "RELEASE_HELM_CHART_TAG=$(helm_chart_image_tag)" >> "$(GITHUB_OUTPUT)"
5151

5252
@echo "Release complete!"
5353

5454
.PHONY: release-debian-trust-package
55-
release-debian-trust-package: | $(NEEDS_CRANE)
55+
release-debian-trust-package:
5656
$(MAKE) oci-maybe-push-package_debian
5757

5858
@echo "RELEASE_OCI_PACKAGE_DEBIAN_IMAGE=$(oci_package_debian_image_name)" >> "$(GITHUB_OUTPUT)"

make/_shared/helm/helm.mk

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@ ifndef helm_chart_source_dir
2424
$(error helm_chart_source_dir is not set)
2525
endif
2626

27-
ifndef helm_chart_name
28-
$(error helm_chart_name is not set)
27+
ifndef helm_chart_image_name
28+
$(error helm_chart_image_name is not set)
2929
endif
3030

3131
ifndef helm_chart_version
3232
$(error helm_chart_version is not set)
3333
endif
34-
35-
ifndef helm_chart_app_version
36-
# Default to the same as the chart version
37-
helm_chart_app_version = $(helm_chart_version)
34+
ifneq ($(helm_chart_version:v%=v),v)
35+
$(error helm_chart_version "$(helm_chart_version)" should start with a "v")
3836
endif
3937

4038
ifndef helm_values_mutation_function
@@ -43,6 +41,9 @@ endif
4341

4442
##########################################
4543

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

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

6566
mkdir -p $(dir $@)
6667
$(HELM) package $(helm_chart_source_dir_versioned) \
67-
--app-version $(helm_chart_app_version) \
68+
--app-version $(helm_chart_version) \
6869
--version $(helm_chart_version) \
6970
--destination $(dir $@)
7071

72+
.PHONY: helm-chart-oci-push
73+
## Create and push Helm chart to OCI registry.
74+
## Will also create a non-v-prefixed tag for the OCI image.
75+
## @category [shared] Publish
76+
helm-chart-oci-push: $(helm_chart_archive) | $(NEEDS_HELM) $(NEEDS_CRANE)
77+
$(HELM) push "$(helm_chart_archive)" "oci://$(helm_chart_image_registry)"
78+
$(CRANE) copy "$(helm_chart_image_name):$(helm_chart_image_tag)" "$(helm_chart_image_name):$(helm_chart_image_tag:v%=%)"
79+
7180
.PHONY: helm-chart
7281
## Create a helm chart
7382
## @category [shared] Helm Chart

0 commit comments

Comments
 (0)