Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6fd40c0

Browse filesBrowse files
committed
Fix Helm chart version bump script
Instead of relying on semver which is not installed, just parse it with bash.
1 parent 63c0719 commit 6fd40c0
Copy full SHA for 6fd40c0

1 file changed

+57-8Lines changed: 57 additions & 8 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎ci/build/update-repo.sh‎

Copy file name to clipboardExpand all lines: ci/build/update-repo.sh
+57-8Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,65 @@
22

33
set -Eeuo pipefail
44

5+
# Given versions $1 and $2 figure out the first component that is different
6+
# (major, minor, patch).
7+
function find_version_diff() {
8+
# shellcheck disable=SC2206
9+
local a=( ${1//./ } )
10+
# shellcheck disable=SC2206
11+
local b=( ${2//./ } )
12+
13+
if [[ ${a[0]} != "${b[0]}" ]] ; then
14+
echo major
15+
elif [[ ${a[1]} != "${b[1]}" ]] ; then
16+
echo minor
17+
else
18+
echo patch
19+
fi
20+
}
21+
22+
# Bump $1 by the bump type (major, minor, patch) in $2.
23+
function bump_version() {
24+
# shellcheck disable=SC2206
25+
local a=( ${1//./ } )
26+
case $2 in
27+
major)
28+
((a[0]++))
29+
a[1]=0
30+
a[2]=0
31+
;;
32+
minor)
33+
((a[1]++))
34+
a[2]=0
35+
;;
36+
*)
37+
((a[2]++))
38+
;;
39+
esac
40+
echo "${a[0]}.${a[1]}.${a[2]}"
41+
}
42+
543
function update_helm() {
6-
local current
7-
current=$(yq .version ci/helm-chart/Chart.yaml)
8-
local next
9-
next=$(semver "$current" -i minor)
10-
echo "Bumping version from $current to $next..."
11-
sed -i.bak "s/^version: $current\$/version: $next/" ci/helm-chart/Chart.yaml
12-
13-
echo "Setting app version and image to $version..."
44+
local chart_version
45+
chart_version=$(yq .version ci/helm-chart/Chart.yaml)
46+
local app_version
47+
app_version=$(yq .appVersion ci/helm-chart/Chart.yaml)
48+
local image_version
49+
image_version=$(yq .image.tag ci/helm-chart/values.yaml)
50+
51+
local bump_type
52+
bump_type=$(find_version_diff "$app_version" "$version")
53+
local chart_version_bump
54+
chart_version_bump=$(bump_version "$chart_version" "$bump_type")
55+
56+
# Use sed to replace because yq will reformat.
57+
echo "Bumping version from $chart_version to $chart_version_bump..."
58+
sed -i.bak "s/^version: $chart_version\$/version: $chart_version_bump/" ci/helm-chart/Chart.yaml
59+
60+
echo "Bumping app version from $app_version to $version..."
1461
sed -i.bak "s/^appVersion: .\+\$/appVersion: $version/" ci/helm-chart/Chart.yaml
62+
63+
echo "Bumping image version from $image_version to $version..."
1564
sed -i.bak "s/^ tag: .\+\$/ tag: '$version'/" ci/helm-chart/values.yaml
1665
}
1766

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.