From 770fa142ff146084962c04d49d675f8697003906 Mon Sep 17 00:00:00 2001 From: coutug Date: Tue, 26 Mar 2024 12:39:11 -0400 Subject: [PATCH] update renovate --- renovate.json | 11 +++++++++- scripts/bump-chart-version.sh | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 scripts/bump-chart-version.sh diff --git a/renovate.json b/renovate.json index 97e584d..faac057 100644 --- a/renovate.json +++ b/renovate.json @@ -1,5 +1,7 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "allowPostUpgradeCommandTemplating": true, + "allowedPostUpgradeCommands": ["^.*"], "extends": [ "config:recommended" ], @@ -24,7 +26,14 @@ { "matchDatasources": ["docker"], "matchPackageNames": ["ghcr.io/coutug/mini-app"], - "registryUrls": ["ghcr.io"] + "registryUrls": ["ghcr.io"], + "postUpgradeTasks": { + "commands": [ + "bash scripts/bump-chart-version.sh '{{{parentDir}}}' '{{{isMajor}}}' '{{{isMinor}}}' '{{{isPatch}}}'" + ], + "fileFilters": ["**/Chart.yaml"], + "executionMode": "branch" + } }, { "matchManagers": ["flux"], diff --git a/scripts/bump-chart-version.sh b/scripts/bump-chart-version.sh new file mode 100644 index 0000000..292ce63 --- /dev/null +++ b/scripts/bump-chart-version.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -euo pipefail + +parent_dir="$1" +is_major="$2" +is_minor="$3" +is_patch="$4" + +version=$(grep "^version:" "charts/${parent_dir}/Chart.yaml" | awk '{print $2}') +if [[ ! $version ]]; then + echo "No valid version was found" + exit 1 +fi + +major=$(echo "$version" | cut -d. -f1) +minor=$(echo "$version" | cut -d. -f2) +patch=$(echo "$version" | cut -d. -f3) + +# Bump major version +if [[ "$is_major" = 'true' ]]; then + major=$(( major + 1 )) + minor=0 + patch=0 +fi + +# Bump minor version +if [[ "$is_minor" = 'true' ]]; then + minor=$(( minor + 1 )) + patch=0 +fi + +# Bump patch version +if [[ "$is_patch" = 'true' ]]; then + patch=$(( patch + 1 )) +fi + +echo "Bumping version for $parent_dir from $version to $major.$minor.$patch" +sed -i "s/^version:.*/version: ${major}.${minor}.${patch}/g" "charts/${parent_dir}/Chart.yaml" \ No newline at end of file