istio.io/istio@v0.0.0-20240520182934-d79c90f27776/operator/scripts/run_update_branch.sh (about) 1 #!/bin/bash 2 3 # Copyright Istio Authors 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 set -x 18 set -e 19 20 WD=$(dirname "$0") 21 WD=$(cd "$WD"; pwd) 22 ROOT=$(dirname "$WD") 23 24 MANIFESTS_DIR="${ROOT}/../manifests" 25 26 function update_branch() { 27 local FROM="${1}" 28 local TO="${2}" 29 30 if [ "${FROM}" != "${TO}" ]; then 31 echo "Updating version for branch ${TO}..." 32 # Update version string in docs. 33 sed -i "s|blob/${FROM}|blob/${TO}|g" "${ROOT}"/ARCHITECTURE.md 34 sed -i "s|blob/${FROM}|blob/${TO}|g" "${ROOT}"/README.md 35 # Update tag for building profiles. 36 find "${MANIFESTS_DIR}"/profiles -type f -exec sed -i "s/tag: ${FROM}-latest-daily/tag: ${TO}-latest-daily/g" {} \; 37 # Update tag for testdata. 38 find "${ROOT}"/cmd/mesh/testdata -type f -exec sed -i "s/tag: ${FROM}-latest-daily/tag: ${TO}-latest-daily/g" {} \; 39 find "${ROOT}"/pkg/values/testdata -type f -exec sed -i "s/tag: ${FROM}-latest-daily/tag: ${TO}-latest-daily/g" {} \; 40 # Update operator version. 41 find "${ROOT}"/version -type f -exec sed -r "s/[0-9]+\.[0-9]+\.[0-9]+/${OPERATOR_VERSION}/g" {} \; 42 fi 43 } 44 45 FROM_BRANCH=${FROM_BRANCH:-master} 46 CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)" 47 48 SHORT_VERSION=${CURRENT_BRANCH//release-/} 49 [[ ${SHORT_VERSION} =~ ^[0-9]+\.[0-9]+ ]] && SHORT_VERSION=${BASH_REMATCH[0]} 50 PATCH_VERSION=${PATCH_VERSION:-0} 51 OPERATOR_VERSION="${SHORT_VERSION}.${PATCH_VERSION}" 52 53 update_branch "${FROM_BRANCH}" "${CURRENT_BRANCH}"