Skip to content

Commit

Permalink
use a 'latest' tag for releases (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
djeebus authored Apr 11, 2024
1 parent cbd0da7 commit 1ec65d3
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 20 deletions.
6 changes: 5 additions & 1 deletion .github/actions/build-image/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions .github/workflows/on_release_published.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ jobs:
- uses: ./.github/actions/build-image
with:
image_tag: ${{ github.ref_name }}
tag_latest: true
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ci-helm:
BUILD +test-helm
BUILD +release-helm

build:
docker-multiarch:
BUILD --platform=linux/amd64 --platform=linux/arm64 +docker

release:
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions charts/kubechecks/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
apiVersion: v2
name: kubechecks
description: A Helm chart for kubechecks
version: 0.4.3
appVersion: "1.3.3"
version: 0.4.4
type: application
maintainers:
- name: zapier
8 changes: 3 additions & 5 deletions charts/kubechecks/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ Common labels
{{- define "kubechecks.labels" -}}
helm.sh/chart: {{ include "kubechecks.chart" . }}
{{ include "kubechecks.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ coalesce .Values.deployment.image.tag .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/version: {{ .Values.deployment.image.tag }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.commonLabels }}
{{ toYaml .Values.commonLabels }}
{{- with .Values.commonLabels }}
{{ . | toYaml }}
{{- end }}
{{- end }}

Expand Down
5 changes: 2 additions & 3 deletions charts/kubechecks/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ metadata:
{{- with .Values.deployment.annotations }}
annotations: {{ toYaml . | nindent 4 }}
{{- end}}
labels:
{{- include "kubechecks.labels" . | nindent 4 }}
labels: {{- include "kubechecks.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.deployment.replicaCount }}
selector:
Expand Down Expand Up @@ -36,7 +35,7 @@ spec:
containers:
- name: {{ .Chart.Name }}
{{- with .Values.deployment.image }}
image: "{{ .name }}:{{ coalesce .tag (printf "v%s" $.Chart.AppVersion) }}"
image: "{{ .name }}:{{ required "must set .deployment.image.tag" .tag }}"
imagePullPolicy: {{ .pullPolicy }}
{{- end }}
{{- with .Values.deployment.args }}
Expand Down
7 changes: 5 additions & 2 deletions charts/kubechecks/tests/configmap_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ values: [basics.min-values.yaml]
tests:
- it: should render
chart:
appVersion: 1.0.0
version: 0.1.0
set:
deployment:
image:
tag: 1.0.0
release:
name: kubechecks
asserts:
- isKind:
of: ConfigMap
- equal:
path: data
value:
value:
KUBECHECKS_ARGOCD_API_INSECURE: "false"
KUBECHECKS_TEST_VALUE: Hello
- equal:
Expand Down
19 changes: 16 additions & 3 deletions charts/kubechecks/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@ 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
set:
deployment:
image:
tag: v1.0.0
chart:
appVersion: 1.0.0
version: 0.1.0
release:
name: kubechecks
Expand All @@ -16,15 +28,16 @@ tests:
of: Deployment
- equal:
path: spec.template.spec.containers[0].image
value: ghcr.io/zapier/kubechecks:v1.0.0 # App Version, not chart versions
value: ghcr.io/zapier/kubechecks:v1.0.0
- equal:
path: metadata.labels
value:
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:
Expand Down
2 changes: 1 addition & 1 deletion charts/kubechecks/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ deployment:
image:
pullPolicy: Always
name: "ghcr.io/zapier/kubechecks"
tag: "" # Defaults to the .Chart.AppVersion
tag: "latest"

imagePullSecrets: []

Expand Down

0 comments on commit 1ec65d3

Please sign in to comment.