From 3b9887c66c7e47d40dd9545f6763f88c072d187d Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Wed, 12 Apr 2023 13:49:25 +0100 Subject: [PATCH] Use helm .Chart.AppVersion instead of specifying value (#9933) * Use helm .Chart.AppVersion instead of specifying value * Backwards compatibility with existing process for deploying chart from source where Chart.AppVersion hasn't been generated yet --- .github/workflows/deploy-cloud.yaml | 2 +- charts/budibase/templates/app-service-deployment.yaml | 6 +++++- charts/budibase/templates/proxy-service-deployment.yaml | 6 +++++- charts/budibase/templates/worker-service-deployment.yaml | 6 +++++- charts/budibase/values.yaml | 2 +- scripts/releaseHelmChart.js | 7 ------- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy-cloud.yaml b/.github/workflows/deploy-cloud.yaml index fa80da846f..5bc3f0bbca 100644 --- a/.github/workflows/deploy-cloud.yaml +++ b/.github/workflows/deploy-cloud.yaml @@ -55,7 +55,7 @@ jobs: config-files: values.production.yaml chart-path: charts/budibase namespace: budibase - values: globals.appVersion=v${{ env.RELEASE_VERSION }},services.couchdb.url=${{ secrets.PRODUCTION_COUCHDB_URL }},services.couchdb.password=${{ secrets.PRODUCTION_COUCHDB_PASSWORD }} + values: globals.appVersion=${{ env.RELEASE_VERSION }},services.couchdb.url=${{ secrets.PRODUCTION_COUCHDB_URL }},services.couchdb.password=${{ secrets.PRODUCTION_COUCHDB_PASSWORD }} name: budibase-prod - name: Discord Webhook Action diff --git a/charts/budibase/templates/app-service-deployment.yaml b/charts/budibase/templates/app-service-deployment.yaml index 6ba9337f5b..e7abf82de0 100644 --- a/charts/budibase/templates/app-service-deployment.yaml +++ b/charts/budibase/templates/app-service-deployment.yaml @@ -199,7 +199,11 @@ spec: value: {{ .Values.services.tlsRejectUnauthorized }} {{ end }} - image: budibase/apps:{{ .Values.globals.appVersion }} + {{ if .Values.globals.appVersion }} + image: budibase/apps:v{{ .Values.globals.appVersion }} + {{ else }} + image: budibase/apps:v{{ .Chart.AppVersion }} + {{ end }} imagePullPolicy: Always livenessProbe: httpGet: diff --git a/charts/budibase/templates/proxy-service-deployment.yaml b/charts/budibase/templates/proxy-service-deployment.yaml index 42af458a8c..191f892565 100644 --- a/charts/budibase/templates/proxy-service-deployment.yaml +++ b/charts/budibase/templates/proxy-service-deployment.yaml @@ -37,7 +37,11 @@ spec: {{ end }} spec: containers: - - image: budibase/proxy:{{ .Values.globals.appVersion }} + {{ if .Values.globals.appVersion }} + image: budibase/proxy:v{{ .Values.globals.appVersion }} + {{ else }} + image: budibase/proxy:v{{ .Chart.AppVersion }} + {{ end }} imagePullPolicy: Always name: proxy-service ports: diff --git a/charts/budibase/templates/worker-service-deployment.yaml b/charts/budibase/templates/worker-service-deployment.yaml index 0df295b5d6..69f864cfc0 100644 --- a/charts/budibase/templates/worker-service-deployment.yaml +++ b/charts/budibase/templates/worker-service-deployment.yaml @@ -189,7 +189,11 @@ spec: value: {{ .Values.services.tlsRejectUnauthorized }} {{ end }} - image: budibase/worker:{{ .Values.globals.appVersion }} + {{ if .Values.globals.appVersion }} + image: budibase/worker:v{{ .Values.globals.appVersion }} + {{ else }} + image: budibase/worker:v{{ .Chart.AppVersion }} + {{ end }} imagePullPolicy: Always livenessProbe: httpGet: diff --git a/charts/budibase/values.yaml b/charts/budibase/values.yaml index dbf6b6b46e..2d89e81b7f 100644 --- a/charts/budibase/values.yaml +++ b/charts/budibase/values.yaml @@ -74,7 +74,7 @@ tolerations: [] affinity: {} globals: - appVersion: "latest" + appVersion: "" # Use as an override to .Chart.AppVersion budibaseEnv: PRODUCTION tenantFeatureFlags: "*:LICENSING,*:USER_GROUPS,*:ONBOARDING_TOUR" enableAnalytics: "1" diff --git a/scripts/releaseHelmChart.js b/scripts/releaseHelmChart.js index 0e469bd012..45ae01df0e 100755 --- a/scripts/releaseHelmChart.js +++ b/scripts/releaseHelmChart.js @@ -2,15 +2,8 @@ const yaml = require("js-yaml") const fs = require("fs") const path = require("path") -const UpgradeTypes = { - MAJOR: "major", - MINOR: "minor", - PATCH: "patch" -} - const CHART_PATH = path.join(__dirname, "../", "charts", "budibase", "Chart.yaml") const UPGRADE_VERSION = process.env.BUDIBASE_RELEASE_VERSION -const UPGRADE_TYPE = process.env.HELM_CHART_UPGRADE_TYPE || UpgradeTypes.PATCH if (!UPGRADE_VERSION) { throw new Error("BUDIBASE_RELEASE_VERSION env var must be set.")