vitess.io/vitess@v0.16.2/tools/release_utils.sh (about) 1 #!/bin/bash 2 3 # Copyright 2023 The Vitess 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 function checkGitState() { 18 git_status_output=$(git status --porcelain) 19 if [ "$git_status_output" == "" ]; then 20 echo so much clean 21 else 22 echo "cannot do release with dirty git state" 23 exit 1 24 fi 25 } 26 27 function updateDockerReleaseScript () { 28 sed -i.bak -E "s/vt_base_version=.*/vt_base_version='v$1'/g" $ROOT/docker/release.sh 29 rm -f $ROOT/docker/release.sh.bak 30 } 31 32 function checkoutNewBranch () { 33 branch_name=$1 34 35 current_branch=$BASE_BRANCH-$branch_name-1 36 37 failed=0 38 git checkout -b $current_branch $BASE_REMOTE/$BASE_BRANCH || failed=1 39 for (( i = 2; $failed != 0; i++ )); do 40 failed=0 41 current_branch=$BASE_BRANCH-$branch_name-$i 42 git checkout -b $current_branch $BASE_REMOTE/$BASE_BRANCH || failed=1 43 done 44 } 45 46 function updateVersionGo () { 47 YEAR=$(date +'%Y') 48 cat << EOF > ${ROOT}/go/vt/servenv/version.go 49 /* 50 Copyright $YEAR The Vitess Authors. 51 52 Licensed under the Apache License, Version 2.0 (the "License"); 53 you may not use this file except in compliance with the License. 54 You may obtain a copy of the License at 55 56 http://www.apache.org/licenses/LICENSE-2.0 57 58 Unless required by applicable law or agreed to in writing, software 59 distributed under the License is distributed on an "AS IS" BASIS, 60 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 61 See the License for the specific language governing permissions and 62 limitations under the License. 63 */ 64 65 package servenv 66 67 // THIS FILE IS AUTO-GENERATED DURING NEW RELEASES BY ./tools/do_releases.sh 68 // DO NOT EDIT 69 70 const versionName = "${1}" 71 EOF 72 73 } 74 75 function updateJava () { 76 cd $ROOT/java || exit 1 77 mvn versions:set -DnewVersion=$1 78 } 79 80 # First argument is the Release Version (for instance: v12.0.0) 81 # Second argument is the Vitess Operator version 82 function updateVitessExamples () { 83 compose_example_files=$(find -E $ROOT/examples/compose/* -regex ".*.(go|yml)") 84 compose_example_sub_files=$(find -E $ROOT/examples/compose/**/* -regex ".*.(go|yml)") 85 vtop_example_files=$(find -E $ROOT/examples/operator -name "*.yaml") 86 sed -i.bak -E "s/vitess\/lite:(.*)/vitess\/lite:v$1/g" $compose_example_files $compose_example_sub_files $vtop_example_files 87 sed -i.bak -E "s/vitess\/vtadmin:(.*)/vitess\/vtadmin:v$1/g" $compose_example_files $compose_example_sub_files $vtop_example_files 88 sed -i.bak -E "s/vitess\/lite:\${VITESS_TAG:-latest}/vitess\/lite:v$1/g" $compose_example_sub_files $vtop_example_files 89 sed -i.bak -E "s/vitess\/lite:(.*)-mysql80/vitess\/lite:v$1-mysql80/g" $(find -E $ROOT/examples/operator -name "*.md") 90 if [ "$2" != "" ]; then 91 sed -i.bak -E "s/planetscale\/vitess-operator:(.*)/planetscale\/vitess-operator:v$2/g" $vtop_example_files 92 fi 93 rm -f $(find -E $ROOT/examples/operator -regex ".*.(md|yaml).bak") 94 rm -f $(find -E $ROOT/examples/compose/* -regex ".*.(go|yml).bak") 95 rm -f $(find -E $ROOT/examples/compose/**/* -regex ".*.(go|yml).bak") 96 }