From 3eebefcdf40b0f882cbfb74f977d8efab1660d39 Mon Sep 17 00:00:00 2001 From: Johannes Kastl Date: Sun, 2 Nov 2025 13:42:31 +0100 Subject: [PATCH] ADD scripts/update_chart.sh --- scripts/update_chart.sh | 70 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 scripts/update_chart.sh diff --git a/scripts/update_chart.sh b/scripts/update_chart.sh new file mode 100755 index 0000000..9d41332 --- /dev/null +++ b/scripts/update_chart.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +set -o pipefail + +[[ "${#}" == "2" ]] || { + echo "Please give the chart name and the update type as only arguments" + exit 3 +} + +CHART="$1" +UPDATE_TYPE="$2" + + +appversion="$(awk '/^appVersion:/ {print $2}' "charts/${CHART}/Chart.yaml")" + +version="$(awk '/^version:/ {print $2}' "charts/${CHART}/Chart.yaml")" +echo "Old version is ${version}" +major="$(echo "${version}" | cut -d. -f1)" +minor="$(echo "${version}" | cut -d. -f2)" +patch="$(echo "${version}" | cut -d. -f3)" + +if [[ "${UPDATE_TYPE}" =~ (major|replacement) ]] +then + major="$(( major + 1 ))" + minor=0 + patch=0 +elif [[ "${UPDATE_TYPE}" =~ 'minor' ]] +then + minor="$(( minor + 1 ))" + patch=0 +else + patch="$(( patch + 1 ))" +fi + +newversion="${major}.${minor}.${patch}" +echo "New version is ${newversion}" + +# change version in Chart.yaml +sed -i "s/^version:.*/version: ${newversion}/g" "charts/${CHART}/Chart.yaml" + +# change artifacthub annotation in Chart.yaml +sed -i "s/- kind: .*$/- kind: changed/g" "charts/${CHART}/Chart.yaml" +sed -i "/kind/ {n; s/description:.*/description: update appVersion to ${appversion}/g}" "charts/${CHART}/Chart.yaml" + +# change versions in README.md +sed -i "/img.shields.io/ s/Version\\: ${version}/Version: ${newversion}/g" "charts/${CHART}/README.md" +sed -i "/img.shields.io/ s/Version-${version}-informational/Version-${newversion}-informational/g" "charts/${CHART}/README.md" + +changelog=" +### Version ${newversion} + +#### Added + +N/A + +#### Changed + +* update appVersion to ${appversion} + +#### Fixed + +N/A" + +if [[ -n "${appversion}" ]] +then + sed -i "/adheres/r /dev/stdin"<<< "${changelog}" -- "charts/${CHART}/README_CHANGELOG.md.gotmpl" +else + # nothing to do, as this is a library chart without an appVersion + true +fi