-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathupdate-helm-chart.sh
executable file
·45 lines (33 loc) · 1.3 KB
/
update-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
#!/bin/bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
CHART_DIR="charts/hcp-terraform-operator"
CHART_FILE="Chart.yaml"
# Update the 'Chart.yaml' file with a new version of the Operator image tag.
function update_chart_file {
C_VERSION=`yq '.appVersion' $CHART_DIR/$CHART_FILE`
C_CHART_VERSION=`yq '.version' $CHART_DIR/$CHART_FILE`
if [[ $C_VERSION == $HCP_TF_OPERATOR_RELEASE_VERSION && $C_CHART_VERSION == $HCP_TF_OPERATOR_RELEASE_VERSION ]]; then
echo "No changes in the $CHART_FILE file."
return 0
fi
echo "Updating the $CHART_FILE file."
yq \
--inplace \
'.appVersion = strenv(HCP_TF_OPERATOR_RELEASE_VERSION) | .version = strenv(HCP_TF_OPERATOR_RELEASE_VERSION)' $CHART_DIR/$CHART_FILE
}
function main {
if [[ -z "${HCP_TF_OPERATOR_RELEASE_VERSION}" ]]; then
echo "The environment variable HCP_TF_OPERATOR_RELEASE_VERSION is not set."
exit 1
fi
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD | sed -e 's/^release\/v//'`
if [[ "$HCP_TF_OPERATOR_RELEASE_VERSION" != "$GIT_BRANCH" ]]; then
echo "The version in the git branch name '${GIT_BRANCH}' does not match with the release version '${HCP_TF_OPERATOR_RELEASE_VERSION}'."
echo "Exiting!"
exit 1
fi
echo "Version: ${HCP_TF_OPERATOR_RELEASE_VERSION}"
update_chart_file
}
main