diff --git a/.github/workflows/debian-trust-package-release.yaml b/.github/workflows/debian-trust-package-release.yaml index 787c232d..14c544ee 100644 --- a/.github/workflows/debian-trust-package-release.yaml +++ b/.github/workflows/debian-trust-package-release.yaml @@ -6,7 +6,7 @@ on: - make/00_debian_version.mk jobs: - build_images: + build_and_push: runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6ffdaf23..34288bad 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -8,7 +8,7 @@ env: VERSION: ${{ github.ref_name }} jobs: - build_images: + build_and_push: runs-on: ubuntu-latest permissions: @@ -36,24 +36,18 @@ 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 - needs: build_images + needs: build_and_push permissions: contents: write # needed for creating a PR @@ -62,17 +56,12 @@ jobs: steps: - run: | touch .notes-file - echo "OCI_MANAGER_IMAGE: ${{ needs.build_images.outputs.RELEASE_OCI_MANAGER_IMAGE }}" >> .notes-file - 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 "OCI_MANAGER_IMAGE: ${{ needs.build_and_push.outputs.RELEASE_OCI_MANAGER_IMAGE }}" >> .notes-file + echo "OCI_MANAGER_TAG: ${{ needs.build_and_push.outputs.RELEASE_OCI_MANAGER_TAG }}" >> .notes-file + echo "OCI_PACKAGE_DEBIAN_IMAGE: ${{ needs.build_and_push.outputs.RELEASE_OCI_PACKAGE_DEBIAN_IMAGE }}" >> .notes-file + echo "OCI_PACKAGE_DEBIAN_TAG: ${{ needs.build_and_push.outputs.RELEASE_OCI_PACKAGE_DEBIAN_TAG }}" >> .notes-file + echo "HELM_CHART_IMAGE: ${{ needs.build_and_push.outputs.RELEASE_HELM_CHART_IMAGE }}" >> .notes-file + echo "HELM_CHART_TAG: ${{ needs.build_and_push.outputs.RELEASE_HELM_CHART_TAG }}" >> .notes-file - env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -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" diff --git a/klone.yaml b/klone.yaml index 65303808..9c521740 100644 --- a/klone.yaml +++ b/klone.yaml @@ -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 diff --git a/make/00_mod.mk b/make/00_mod.mk index ca038dea..777e4703 100644 --- a/make/00_mod.mk +++ b/make/00_mod.mk @@ -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 diff --git a/make/02_mod.mk b/make/02_mod.mk index 1427e4e4..f2af3e0f 100644 --- a/make/02_mod.mk +++ b/make/02_mod.mk @@ -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)" diff --git a/make/_shared/helm/helm.mk b/make/_shared/helm/helm.mk index 626affde..097dc6ed 100644 --- a/make/_shared/helm/helm.mk +++ b/make/_shared/helm/helm.mk @@ -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 @@ -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 @@ -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