Skip to content

Commit

Permalink
Merge pull request #263 from mjura/master-github
Browse files Browse the repository at this point in the history
Update update-rancher-charts.sh for github workflows
  • Loading branch information
mjura authored Aug 29, 2023
2 parents 943847a + 28dc3ff commit 1934082
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions .github/scripts/update-rancher-charts.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/bin/bash
#
# Submit new AKS operator version against rancher/charts
# Submit new operator version against rancher/charts

set -ue

PREV_AKS_OPERATOR_VERSION="$1" # e.g. 1.1.0-rc3
NEW_AKS_OPERATOR_VERSION="$2"
PREV_OPERATOR_VERSION="$1" # e.g. 1.1.0-rc3
NEW_OPERATOR_VERSION="$2"
PREV_CHART_VERSION="$3" # e.g. 101.2.0
NEW_CHART_VERSION="$4"
REPLACE="$5" # remove previous version if `true`, otherwise add new

OPERATOR="${OPERATOR:-aks-operator}"

if [ -z "${GITHUB_WORKSPACE:-}" ]; then
CHARTS_DIR="$(dirname -- "$0")/../../../charts"
else
Expand All @@ -27,36 +29,37 @@ if [ ! -f bin/charts-build-scripts ]; then
make pull-scripts
fi

find ./packages/rancher-aks-operator/ -type f -exec sed -i -e "s/${PREV_AKS_OPERATOR_VERSION}/${NEW_AKS_OPERATOR_VERSION}/g" {} \;
find ./packages/rancher-aks-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 "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 "s/doNotRelease: false//g" {} \;

if [ "${REPLACE}" == "true" ] && grep -q "rancher-aks-operator:" release.yaml; then
sed -i -e "s/${PREV_CHART_VERSION}+up${PREV_AKS_OPERATOR_VERSION}/${NEW_CHART_VERSION}+up${NEW_AKS_OPERATOR_VERSION}/g" release.yaml
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-aks-operator:" release.yaml; then
sed -i -e "s/${PREV_CHART_VERSION}+up${PREV_AKS_OPERATOR_VERSION}/${PREV_CHART_VERSION}+up${PREV_AKS_OPERATOR_VERSION}\n - ${NEW_CHART_VERSION}+up${NEW_AKS_OPERATOR_VERSION}/g" release.yaml
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-aks-operator:
- ${PREV_CHART_VERSION}+up${PREV_AKS_OPERATOR_VERSION}
- ${NEW_CHART_VERSION}+up${NEW_AKS_OPERATOR_VERSION}
rancher-aks-operator-crd:
- ${PREV_CHART_VERSION}+up${PREV_AKS_OPERATOR_VERSION}
- ${NEW_CHART_VERSION}+up${NEW_AKS_OPERATOR_VERSION}" >> release.yaml
# remove empty line above rancher-aks-operator
sed -i -z -e "s/[[:space:]]*\nrancher-aks-operator:/\nrancher-aks-operator:/g" release.yaml
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-aks-operator release.yaml
git commit -m "Updating to AKS Operator v${NEW_AKS_OPERATOR_VERSION}"
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-aks-operator rancher-aks-operator-crd; do CHART=$i VERSION=${PREV_CHART_VERSION}+up${PREV_AKS_OPERATOR_VERSION} make remove; done
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-aks-operator make charts
git add assets/rancher-aks-operator* charts/rancher-aks-operator* index.yaml
git commit -m "Autogenerated changes for AKS Operator v${NEW_AKS_OPERATOR_VERSION}"
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

0 comments on commit 1934082

Please sign in to comment.