-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrelease_subchart.sh
executable file
·93 lines (54 loc) · 2.4 KB
/
release_subchart.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
set -e
if [ -z "$CI" ]; then
echo "Usage ./release_subchart sources/NAME"
echo "Usage ./release_subchart NAME"
echo "Usage ./release_subchart sources/NAME VERSION"
echo "Default version is latest version"
if [ $(yq -V | grep version | wc -l ) -ne 1 ]; then
echo "This script uses yq to update yaml files. You need to have it installed"
echo "Use https://github.com/mikefarah/yq"
echo "To install latest version run: "
echo "wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq &&\
chmod +x /usr/bin/yq"
exit 1
fi
fi
if [ $# -gt 0 ]; then
HELM_SUBCHART=$( echo $1 | sed 's/sources//g' | sed 's|/||g' )
HELM_SUBCHART_VERSION=$2
fi
if [ -z "$HELM_SUBCHART" ]; then
echo "This script needs to receive the HELM_SUBCHART variable"
exit 1
fi
if [ -z "$HELM_SUBCHART_VERSION" ]; then
echo "Did not receive the version, will use latest version"
HELM_SUBCHART_VERSION=$(yq '.version' sources/$HELM_SUBCHART/Chart.yaml )
echo $HELM_SUBCHART_VERSION
fi
echo " Trying to update subchart $HELM_SUBCHART version $HELM_SUBCHART_VERSION in all charts "
export HELM_VERSION_TYPE="PATCH"
export HELM_UPGRADE_MESSAGE="Release of dependent chart $HELM_SUBCHART:$HELM_SUBCHART_VERSION"
for i in $(grep $HELM_SUBCHART sources/*/Chart.yaml | awk -F: '{print $1}' | awk -F"/" '{print $2}' | uniq ); do
old_version=$( yq ".dependencies[] | select ( .name == \"$HELM_SUBCHART\" ) | .version" sources/$i/Chart.yaml )
if [ -z $old_version ] && [ ! "$old_version" == "null" ]; then
continue;
fi
if [ "$old_version" == "$HELM_SUBCHART_VERSION" ]; then
echo "Found $i, Subchart $HELM_SUBCHART already version $HELM_SUBCHART_VERSION, skipping"
continue;
fi
bigger_version=$(echo -e "$old_version\n$HELM_SUBCHART_VERSION" | sort -V | tail -n 1)
if [ "$bigger_version" == "$old_version" ]; then
echo "Found $i, Subchart $HELM_SUBCHART has current version, $old_version bigger than $HELM_SUBCHART_VERSION, skipping"
continue;
fi
echo "Updating version"
cd sources/$i
yq -i "( .dependencies[] | select ( .name == \"$HELM_SUBCHART\" ) | .version ) = \"$HELM_SUBCHART_VERSION\"" Chart.yaml
../../increase_version_helm.sh
cd ../..
./update_docs.sh $i
done
echo "Finished updating subcharts"