-
Notifications
You must be signed in to change notification settings - Fork 4
/
update-rancher-charts.sh
executable file
·55 lines (44 loc) · 2.13 KB
/
update-rancher-charts.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
#!/bin/bash
set -ue
if [ -z "${GITHUB_WORKSPACE:-}" ]; then
CHARTS_DIR="$(dirname -- "$0")/../../../charts"
else
CHARTS_DIR="${GITHUB_WORKSPACE}/charts"
fi
pushd "${CHARTS_DIR}" > /dev/null
if [ ! -e ~/.gitconfig ]; then
git config --global user.name "highlander-ci-bot"
git config --global user.email [email protected]
fi
if [ ! -f bin/charts-build-scripts ]; then
make pull-scripts
fi
find ./packages/rancher-${OPERATOR}/ -type f -exec sed -i -e "s/${PREV_OPERATOR_VERSION}/${NEW_OPERATOR_VERSION}/g" {} \;
find ./packages/rancher-${OPERATOR}/ -type f -exec sed -i -e "s/version: ${PREV_CHART_VERSION}/version: ${NEW_CHART_VERSION}/g" {} \;
find ./packages/rancher-${OPERATOR}/ -type f -exec sed -i -e "/doNotRelease: false/d" {} \;
if [ "${REPLACE}" == "true" ] && grep -q "rancher-${OPERATOR}:" release.yaml; then
sed -i -e "s/${PREV_CHART_VERSION}+up${PREV_OPERATOR_VERSION}/${NEW_CHART_VERSION}+up${NEW_OPERATOR_VERSION}/g" release.yaml
else
if grep -q "rancher-${OPERATOR}:" release.yaml; then
sed -i -e "s/${PREV_CHART_VERSION}+up${PREV_OPERATOR_VERSION}/${PREV_CHART_VERSION}+up${PREV_OPERATOR_VERSION}\n - ${NEW_CHART_VERSION}+up${NEW_OPERATOR_VERSION}/g" release.yaml
else
cat <<< "
rancher-${OPERATOR}:
- ${PREV_CHART_VERSION}+up${PREV_OPERATOR_VERSION}
- ${NEW_CHART_VERSION}+up${NEW_OPERATOR_VERSION}
rancher-${OPERATOR}-crd:
- ${PREV_CHART_VERSION}+up${PREV_OPERATOR_VERSION}
- ${NEW_CHART_VERSION}+up${NEW_OPERATOR_VERSION}" >> release.yaml
# remove empty line above rancher-${OPERATOR}
sed -i -z -e "s/[[:space:]]*\nrancher-${OPERATOR}:/\nrancher-${OPERATOR}:/g" release.yaml
fi
fi
git add packages/rancher-${OPERATOR} release.yaml
git commit -m "Updating to Operator v${NEW_OPERATOR_VERSION}"
if [ "${REPLACE}" == "true" ]; then
for i in rancher-${OPERATOR} rancher-${OPERATOR}-crd; do CHART=$i VERSION=${PREV_CHART_VERSION}+up${PREV_OPERATOR_VERSION} make remove; done
fi
PACKAGE=rancher-${OPERATOR} make charts
git add assets/rancher-${OPERATOR}* charts/rancher-${OPERATOR}* index.yaml
git commit -m "Autogenerated changes for Operator v${NEW_OPERATOR_VERSION}"
popd > /dev/null