Skip to content

Commit

Permalink
Added updatecli script to update whereabouts
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Bonafiglia <[email protected]>
  • Loading branch information
rbrtbnfgl committed Jan 22, 2025
1 parent b8986e5 commit c332c37
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
21 changes: 21 additions & 0 deletions updatecli/scripts/update-whereabouts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -eu
if [ -n "$WHEREABOUTS_VERSION" ]; then
app_version=$(echo "$WHEREABOUTS_VERSION" | grep -Eo '^v*[0-9]+.[0-9]+.[0-9]+' | tr -d 'v')
current_whereabouts_version=$(yq '.image.tag' packages/rke2-whereabouts/charts/values.yaml)
current_app_version=$(echo "$current_whereabouts_version" | grep -Eo '^v*[0-9]+.[0-9]+.[0-9]+' | tr -d 'v')
if [ "$current_whereabouts_version" != "$WHEREABOUTS_VERSION" ]; then
echo "Updating Whereabouts chart to $WHEREABOUTS_VERSION"
if [ "$app_version" != "$current_app_version" ]; then
sed -i "s/version: .*/version: $app_version/g" packages/rke2-whereabouts/charts/Chart.yaml
sed -i "s/appVersion: .*/appVersion: $app_version/g" packages/rke2-whereabouts/charts/Chart.yaml
sed -i "s/ tag: $current_whereabouts_version/ tag: $WHEREABOUTS_VERSION/g" packages/rke2-whereabouts/charts/values.yaml
yq -i ".packageVersion = 00" packages/rke2-whereabouts/package.yaml
else
sed -i "s/ tag: $current_whereabouts_version/ tag: $WHEREABOUTS_VERSION/g" packages/rke2-whereabouts/charts/values.yaml
package_version=$(yq '.packageVersion' packages/rke2-whereabouts/package.yaml)
new_version=$(printf "%02d" $(($package_version + 1)))
yq -i ".packageVersion = $new_version" packages/rke2-whereabouts/package.yaml
fi
fi
fi
56 changes: 56 additions & 0 deletions updatecli/updatecli.d/updatewhereabouts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
name: "Update Whereabouts version"

sources:
whereabouts:
name: Get whereabouts version
kind: githubrelease
spec:
owner: rancher
repository: image-build-whereabouts
token: '{{ requiredEnv .github.token }}'
typefilter:
release: true
draft: false
prerelease: false
latest: true
versionfilter:
kind: latest

targets:
whereaboutsImage:
name: "Bump to latest whereabouts version in the chart"
kind: shell
scmid: default
sourceid: whereabouts
spec:
command: 'updatecli/scripts/update-whereabouts.sh'
environments:
- name: WHEREABOUTS_VERSION
value: '{{ source "whereabouts" }}'
- 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 whereabouts version to {{ source "whereabouts" }}'
kind: github/pullrequest
spec:
automerge: false
labels:
- chore
- skip-changelog
- status/auto-created
scmid: default

0 comments on commit c332c37

Please sign in to comment.