This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
generated from AlexsJones/KubeOps
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease_helm_chart.sh
executable file
·81 lines (63 loc) · 1.61 KB
/
release_helm_chart.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
#!/usr/bin/env bash
#set -ex
if ! git diff --quiet; then
echo "You have uncommitted changes, please commit them before running release."
exit 1
fi
HELM_DIR=helm/chart
RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)'
step="$1"
if [ -z "$1" ]
then
step="patch"
fi
chart_version_file="CHART_VERSION"
base="$2"
if [ -z "$2" ]
then
base=$(cat ${chart_version_file})
if [ -z "$base" ]
then
base=0.0.0
fi
fi
# shellcheck disable=SC2001
MAJOR=$(echo $base | sed -e "s#$RE#\1#")
# shellcheck disable=SC2001
MINOR=$(echo $base | sed -e "s#$RE#\2#")
# shellcheck disable=SC2001
PATCH=$(echo $base | sed -e "s#$RE#\3#")
case "$step" in
patch)
PATCH=$(( PATCH + 1 ))
;;
minor)
MINOR=$(( MINOR + 1 ))
PATCH=0
;;
major)
MAJOR=$(( MAJOR + 1 ))
MINOR=0
PATCH=0
;;
esac
new_version="$MAJOR.$MINOR.$PATCH"
echo "$new_version" > ${chart_version_file}
image_version_file="VERSION"
latest_tagged_version="$3"
if [ -z "$3" ]
then
latest_tagged_version=$(git tag --sort=v:refname 2>/dev/null| tail -n 1)
if [ -z "$latest_tagged_version" ]
then
latest_tagged_version=$(cat ${image_version_file})
fi
fi
sed -i "" "s/version: .*/version: $new_version/g" $HELM_DIR/Chart.yaml
sed -i "" "s/appVersion: .*/appVersion: $latest_tagged_version/g" $HELM_DIR/Chart.yaml
git add CHART_VERSION $HELM_DIR
git commit -m "Upgraded helm chart version to $new_version appVersion to $latest_tagged_version"
echo "Upgraded helm chart version to $new_version appVersion to $latest_tagged_version ready to be pushed"
echo "Releasing Helm chart"
echo "Push all staged changes"
git push