2021-10-19 21:04:30 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
## General file setup
|
|
|
|
# $1 bump type
|
|
|
|
# $2 path to chart if one chart only
|
|
|
|
|
|
|
|
|
|
|
|
## Function details
|
|
|
|
# $1 - semver string
|
|
|
|
# $2 - level to incr {patch,minor,major} - patch by default
|
|
|
|
function incr_semver() {
|
|
|
|
IFS='.' read -ra ver <<< "$1"
|
|
|
|
[[ "${#ver[@]}" -ne 3 ]] && echo "Invalid semver string" && return 1
|
|
|
|
[[ "$#" -eq 1 ]] && level='patch' || level=$2
|
|
|
|
|
|
|
|
patch=${ver[2]}
|
|
|
|
minor=${ver[1]}
|
|
|
|
major=${ver[0]}
|
|
|
|
|
|
|
|
case $level in
|
|
|
|
patch)
|
|
|
|
patch=$((patch+1))
|
|
|
|
;;
|
|
|
|
minor)
|
|
|
|
patch=0
|
|
|
|
minor=$((minor+1))
|
|
|
|
;;
|
|
|
|
major)
|
|
|
|
patch=0
|
|
|
|
minor=0
|
|
|
|
major=$((major+1))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Invalid level passed"
|
|
|
|
return 2
|
|
|
|
esac
|
|
|
|
echo "$major.$minor.$patch"
|
|
|
|
}
|
|
|
|
|
|
|
|
BUMPTYPE=${1}
|
|
|
|
if [ -z ${2+x} ]; then
|
2021-11-14 10:43:45 +00:00
|
|
|
for train in stable incubator develop non-free deprecated dependency core; do
|
2021-10-19 21:04:30 +00:00
|
|
|
for chart in charts/${train}/*; do
|
|
|
|
if [ -d "${chart}" ]; then
|
|
|
|
echo "Bumping patch version for ${train}/${chart}"
|
2021-10-20 22:00:57 +00:00
|
|
|
OLDVER=$(cat ${chart}/Chart.yaml | grep "^version: ")
|
2021-10-19 21:04:30 +00:00
|
|
|
OLDVER=${OLDVER#version: }
|
|
|
|
NEWVER=$(incr_semver ${OLDVER} ${BUMPTYPE})
|
2021-10-20 22:00:57 +00:00
|
|
|
sed -i "s|^version:.*|version: ${NEWVER}|g" ${chart}/Chart.yaml
|
2021-10-19 21:04:30 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
else
|
|
|
|
chart=${2}
|
|
|
|
if [ -d "${chart}" ]; then
|
|
|
|
echo "Bumping patch version for ${chart}"
|
2021-10-20 22:00:57 +00:00
|
|
|
OLDVER=$(cat ${chart}/Chart.yaml | grep "^version: ")
|
2021-10-19 21:04:30 +00:00
|
|
|
OLDVER=${OLDVER#version: }
|
|
|
|
NEWVER=$(incr_semver ${OLDVER} ${BUMPTYPE})
|
2021-10-20 22:00:57 +00:00
|
|
|
sed -i "s|^version:.*|version: ${NEWVER}|g" ${chart}/Chart.yaml
|
2021-10-19 21:04:30 +00:00
|
|
|
fi
|
|
|
|
fi
|