-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbump-chart-versions.sh
executable file
·71 lines (57 loc) · 1.53 KB
/
bump-chart-versions.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
#!/usr/bin/env bash
bump_version() {
local version=$1
local part=$2
# Split the version into an array
IFS='.' read -r -a version_parts <<< "$version"
case $part in
major)
((version_parts[0]++))
version_parts[1]=0
version_parts[2]=0
;;
minor)
((version_parts[1]++))
version_parts[2]=0
;;
patch)
((version_parts[2]++))
;;
esac
echo "${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
}
# Read the current version from the file
current_version=$(yq '.version' ./charts/spv-wallet-stack/Chart.yaml)
echo "Current version: $current_version"
# Determine which part of the version to bump
case $1 in
major | -mj)
version=$(bump_version "$current_version" major)
;;
minor | -m)
version=$(bump_version "$current_version" minor)
;;
patch | -p | "")
version=$(bump_version "$current_version" patch)
;;
*)
echo "Invalid argument: $1"
echo "Usage: $0 [major|minor|patch|-mj|-m|-p]"
exit 1
;;
esac
# Output the new version
echo "New version: $version"
charts=$(find . -name 'Chart.yaml')
echo "Found following Chart files to update version"
echo "$charts"
chartNames=$(echo "$charts" | xargs -I {} yq '.name' {})
echo "Bumping versions"
echo "$charts" | xargs -I {} yq ".version=\"$version\"" -i {}
echo "Updating versions of the dependencies"
echo "$chartNames"
for chart in $charts; do
for chartName in $chartNames; do
yq "(.dependencies[] | select(.name == \"$chartName\").version) |=\"$version\"" -i "$chart"
done
done