From 93feff0b0aa94ef8f44100f7ce5169d2eced5fc1 Mon Sep 17 00:00:00 2001 From: Thomas Ferrandiz Date: Wed, 12 Jun 2024 08:49:34 +0000 Subject: [PATCH] Add multus support in updatecli config --- updatecli/scripts/update-multus.sh | 22 ++++++++++ updatecli/updatecli.d/updatemultus.yaml | 56 +++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100755 updatecli/scripts/update-multus.sh create mode 100644 updatecli/updatecli.d/updatemultus.yaml diff --git a/updatecli/scripts/update-multus.sh b/updatecli/scripts/update-multus.sh new file mode 100755 index 0000000..3fafb98 --- /dev/null +++ b/updatecli/scripts/update-multus.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -eu +if [ -n "$MULTUS_VERSION" ]; then + app_version=$(echo "$MULTUS_VERSION" | grep -Eo 'v[0-9]+.[0-9]+.[0-9]+') + current_multus_version=$(yq '.image.tag' packages/rke2-multus/charts/values.yaml) + current_app_version=$(echo "$current_multus_version" | grep -Eo 'v[0-9]+.[0-9]+.[0-9]+') + if [ "$current_multus_version" != "$MULTUS_VERSION" ]; then + echo "Updating Multus chart to $MULTUS_VERSION" + if [ "$app_version" != "$current_app_version" ]; then + sed -i "s/version: .*/version: $app_version/g" packages/rke2-multus/charts/Chart.yaml + sed -i "s/appVersion: .*/appVersion: $app_version/g" packages/rke2-multus/charts/Chart.yaml + sed -i "s/ tag: $current_app_version/ tag: $app_version/g" packages/rke2-multus/charts/values.yaml + sed -i "s/ tag: $current_multus_version/ tag: $MULTUS_VERSION/g" packages/rke2-multus/charts/values.yaml + yq -i ".packageVersion = 00" packages/rke2-multus/package.yaml + else + sed -i "s/ tag: $current_multus_version/ tag: $MULTUS_VERSION/g" packages/rke2-multus/charts/values.yaml + package_version=$(yq '.packageVersion' packages/rke2-multus/package.yaml) + new_version=$(printf "%02d" $(($package_version + 1))) + yq -i ".packageVersion = $new_version" packages/rke2-multus/package.yaml + fi + fi +fi diff --git a/updatecli/updatecli.d/updatemultus.yaml b/updatecli/updatecli.d/updatemultus.yaml new file mode 100644 index 0000000..0ed0062 --- /dev/null +++ b/updatecli/updatecli.d/updatemultus.yaml @@ -0,0 +1,56 @@ +--- +name: "Update Multus version" + +sources: + calico: + name: Get multus version + kind: githubrelease + spec: + owner: rancher + repository: image-build-multus + token: '{{ requiredEnv .github.token }}' + typefilter: + release: true + draft: false + prerelease: false + latest: true + versionfilter: + kind: latest + +targets: + multusImage: + name: "Bump to latest multus version in the chart" + kind: shell + scmid: default + sourceid: multus + spec: + command: 'updatecli/scripts/update-multus.sh' + environments: + - name: MULTUS_VERSION + value: '{{ source "multus" }}' + - name: PATH + + +scms: + default: + kind: github + spec: + token: '{{ requiredEnv .github.token }}' + username: '{{ requiredEnv .github.username }}' + user: '{{ .github.username }}' + email: '{{ .github.email }}' + owner: '{{ .github.owner }}' + repository: '{{ .github.repository }}' + branch: '{{ .github.branch }}' + +actions: + default: + title: 'Update Multus version to {{ source "multus" }}' + kind: github/pullrequest + spec: + automerge: false + labels: + - chore + - skip-changelog + - status/auto-created + scmid: default