feat(CI): add custom bumping scripting instead of pybump

This commit is contained in:
kjeld Schouten-Lebbing
2021-10-19 23:04:30 +02:00
parent c5a86b1393
commit 512862c393
5 changed files with 64 additions and 47 deletions
+1 -8
View File
@@ -23,13 +23,6 @@ jobs:
fetch-depth: 0 fetch-depth: 0
ref: master ref: master
path: master path: master
- name: Set up Python
uses: actions/setup-python@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pybump
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- uses: dorny/paths-filter@v2 - uses: dorny/paths-filter@v2
id: filter id: filter
with: with:
@@ -68,7 +61,7 @@ jobs:
echo "Version does not have to be bumped" echo "Version does not have to be bumped"
else else
echo "Bumping patch version for ${train}/${chart}" echo "Bumping patch version for ${train}/${chart}"
pybump bump --file ./charts/${train}/${chart}/Chart.yaml --level patch ./bump.sh patch ./charts/${train}/${chart}/Chart.yaml
fi fi
done done
- name: Cleanup - name: Cleanup
-13
View File
@@ -1,13 +0,0 @@
#!/usr/bin/env bash
set -eu
# This script requires pyBump to be installed using pip.
for train in stable incubator develop non-free deprecated; do
for chart in charts/${train}/*; do
if [ -d "${chart}" ]; then
echo "Bumping patch version for ${train}/${chart}"
pybump bump --file ${chart}/Chart.yaml --level major
fi
done
done
-13
View File
@@ -1,13 +0,0 @@
#!/usr/bin/env bash
set -eu
# This script requires pyBump to be installed using pip.
for train in stable incubator develop non-free deprecated; do
for chart in charts/${train}/*; do
if [ -d "${chart}" ]; then
echo "Bumping patch version for ${train}/${chart}"
pybump bump --file ${chart}/Chart.yaml --level minor
fi
done
done
-13
View File
@@ -1,13 +0,0 @@
#!/usr/bin/env bash
set -eu
# This script requires pyBump to be installed using pip.
for train in stable incubator develop non-free deprecated; do
for chart in charts/${train}/*; do
if [ -d "${chart}" ]; then
echo "Bumping patch version for ${train}/${chart}"
pybump bump --file ${chart}/Chart.yaml --level patch
fi
done
done
+63
View File
@@ -0,0 +1,63 @@
#!/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
for train in stable incubator develop non-free deprecated; do
for chart in charts/${train}/*; do
if [ -d "${chart}" ]; then
echo "Bumping patch version for ${train}/${chart}"
OLDVER=$(cat ${chart}/chart.yaml | grep "^version: ")
OLDVER=${OLDVER#version: }
NEWVER=$(incr_semver ${OLDVER} ${BUMPTYPE})
sed -i "s|^version:.*|version: ${NEWVER}|g" ${chart}/chart.yaml
fi
done
done
else
chart=${2}
if [ -d "${chart}" ]; then
echo "Bumping patch version for ${chart}"
OLDVER=$(cat ${chart}/chart.yaml | grep "^version: ")
OLDVER=${OLDVER#version: }
NEWVER=$(incr_semver ${OLDVER} ${BUMPTYPE})
sed -i "s|^version:.*|version: ${NEWVER}|g" ${chart}/chart.yaml
fi
fi