From e4ef592a6f504ab8af2bd42d46a8faae7ee63698 Mon Sep 17 00:00:00 2001 From: "joe.lombrozo" Date: Fri, 22 Mar 2024 15:31:30 -0400 Subject: [PATCH] use a 'latest' tag for releases --- .github/actions/build-image/action.yaml | 6 +++++- .github/workflows/on_release_published.yaml | 1 + .tool-versions | 2 +- Earthfile | 5 +++-- charts/kubechecks/Chart.yaml | 4 ++-- charts/kubechecks/templates/deployment.yaml | 2 +- charts/kubechecks/tests/deployment_test.yaml | 14 ++++++++++++-- 7 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/actions/build-image/action.yaml b/.github/actions/build-image/action.yaml index 1cec541b..900082b3 100644 --- a/.github/actions/build-image/action.yaml +++ b/.github/actions/build-image/action.yaml @@ -5,6 +5,9 @@ inputs: image_tag: description: The image tag required: true + tag_latest: + description: Tag latest as well as the provided tag + default: "false" token: description: Github token required: true @@ -40,6 +43,7 @@ runs: run: >- ./earthly --push - +build + +docker-multiarch + ${{ inputs.tag_latest != 'false' && format('--LATEST_IMAGE_NAME=ghcr.io/{0}:latest', github.repository) || '' }} --GIT_TAG=${{ inputs.image_tag }} --IMAGE_NAME=ghcr.io/${{ github.repository }}:${{ inputs.image_tag }} diff --git a/.github/workflows/on_release_published.yaml b/.github/workflows/on_release_published.yaml index 857e38c4..7d9e0328 100644 --- a/.github/workflows/on_release_published.yaml +++ b/.github/workflows/on_release_published.yaml @@ -19,4 +19,5 @@ jobs: - uses: ./.github/actions/build-image with: image_tag: ${{ github.ref_name }} + tag_latest: true token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.tool-versions b/.tool-versions index ac614c91..91d87df9 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,4 +1,4 @@ -earthly 0.7.23 +earthly 0.8.6 golang 1.21.6 golangci-lint 1.56.1 helm 3.12.2 diff --git a/Earthfile b/Earthfile index aa4faa21..7ab4d831 100644 --- a/Earthfile +++ b/Earthfile @@ -17,7 +17,7 @@ ci-helm: BUILD +test-helm BUILD +release-helm -build: +docker-multiarch: BUILD --platform=linux/amd64 --platform=linux/arm64 +docker release: @@ -129,7 +129,8 @@ docker: CMD ["./kubechecks", "controller"] ARG --required IMAGE_NAME - SAVE IMAGE --push $IMAGE_NAME + ARG LATEST_IMAGE_NAME="" + SAVE IMAGE --push $IMAGE_NAME $LATEST_IMAGE_NAME dlv: ARG --required GOLANG_VERSION diff --git a/charts/kubechecks/Chart.yaml b/charts/kubechecks/Chart.yaml index 2e1c7b31..8c74bfb0 100644 --- a/charts/kubechecks/Chart.yaml +++ b/charts/kubechecks/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 name: kubechecks description: A Helm chart for kubechecks -version: 0.4.3 -appVersion: "1.3.3" +version: 0.4.4 +appVersion: latest type: application maintainers: - name: zapier diff --git a/charts/kubechecks/templates/deployment.yaml b/charts/kubechecks/templates/deployment.yaml index 84c8611e..7a365bb3 100644 --- a/charts/kubechecks/templates/deployment.yaml +++ b/charts/kubechecks/templates/deployment.yaml @@ -36,7 +36,7 @@ spec: containers: - name: {{ .Chart.Name }} {{- with .Values.deployment.image }} - image: "{{ .name }}:{{ coalesce .tag (printf "v%s" $.Chart.AppVersion) }}" + image: "{{ .name }}:{{ coalesce .tag $.Chart.AppVersion }}" imagePullPolicy: {{ .pullPolicy }} {{- end }} {{- with .Values.deployment.args }} diff --git a/charts/kubechecks/tests/deployment_test.yaml b/charts/kubechecks/tests/deployment_test.yaml index 7585558b..59a0be87 100644 --- a/charts/kubechecks/tests/deployment_test.yaml +++ b/charts/kubechecks/tests/deployment_test.yaml @@ -5,9 +5,18 @@ templates: [deployment.yaml] values: [basics.min-values.yaml] tests: + - it: defaults to latest image tag + asserts: + - equal: + path: metadata.labels["app.kubernetes.io/version"] + value: latest + - equal: + path: spec.template.spec.containers[0].image + value: ghcr.io/zapier/kubechecks:latest + - it: should render chart: - appVersion: 1.0.0 + appVersion: v1.0.0 version: 0.1.0 release: name: kubechecks @@ -23,8 +32,9 @@ tests: app.kubernetes.io/instance: kubechecks app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: kubechecks - app.kubernetes.io/version: 1.0.0 + app.kubernetes.io/version: v1.0.0 helm.sh/chart: kubechecks-0.1.0 + - it: should allow arbitrary annotations set: deployment: