Skip to content

Commit cc8a918

Browse files
committed
add updater script
1 parent 31ff5ee commit cc8a918

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

bin/update-helper.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
# ugly-ass script to bump versions in Chart.yaml and regenerate docs
3+
# mostly for working with renovate-generated updates, since it can't update those values
4+
# maybe add it to PR pipeline?
5+
6+
# assign vars from args
7+
chart=${1}
8+
patchlevel=${2}
9+
10+
# exit on no args
11+
if [[ ${1} == "" && ${2} == "" ]];
12+
then
13+
echo "Usage: update-helper.sh chart_name patchlevel"
14+
echo "patchlevel can be either major, minor or patch"
15+
exit 0
16+
fi
17+
18+
# ugly symlink so it works on both linux and OSX
19+
sedlink() {
20+
if [[ "${OSTYPE}" == "linux-gnu"* ]]; then
21+
sed "$@"
22+
elif [[ "${OSTYPE}" == "darwin"* ]]; then
23+
gsed "$@"
24+
else
25+
sed "$@"
26+
fi
27+
}
28+
29+
# function to work with semver, source:
30+
# https://github.com/fmahnke/shell-semver/blob/master/increment_version.sh
31+
semver_increment() {
32+
case ${patchlevel} in
33+
major ) major=true;;
34+
minor ) minor=true;;
35+
patch ) patch=true;;
36+
esac
37+
38+
shift $(($OPTIND - 1))
39+
40+
version=$(grep "version:" charts/${chart}/Chart.yaml | awk {'print $2'})
41+
42+
# Build array from version string.
43+
44+
a=( ${version//./ } )
45+
46+
# Increment version numbers as requested.
47+
48+
if [ ! -z $major ]
49+
then
50+
((a[0]++))
51+
a[1]=0
52+
a[2]=0
53+
fi
54+
55+
if [ ! -z $minor ]
56+
then
57+
((a[1]++))
58+
a[2]=0
59+
fi
60+
61+
if [ ! -z $patch ]
62+
then
63+
((a[2]++))
64+
fi
65+
66+
echo "${a[0]}.${a[1]}.${a[2]}"
67+
}
68+
69+
#set to version we need
70+
target_version=$(semver_increment ${current_version} ${patchlevel})
71+
#patch it around
72+
sedlink -i "s/^version:.*$/version: ${target_version}/g" charts/${chart}/Chart.yaml
73+
#extract image version from values (multiple different images not supported)
74+
appversion=$(grep "tag:" charts/coroot/values.yaml | awk {'print $2'} | tr -d '"')
75+
#patch it around
76+
sedlink -i "s/^appVersion:.*$/appVersion: ${appversion}/g" charts/${chart}/Chart.yaml
77+
#regenerate docs
78+
helm-docs --chart-to-generate charts/${chart}
79+
#add to git staging
80+
git add charts/${chart}
81+
#commit
82+
git commit -m "[${chart}] bump to ${target_version}"

0 commit comments

Comments
 (0)