Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of the release automation script #308

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions tools/release/do_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

ROOT=$(pwd)

if [ "$OLD_VITESS_VERSION" == "" ]; then
echo "Set the env var OLD_VITESS_VERSION with the previous version of Vitess. This value will be used to prepare the upgrade endtoend tests."
exit 1
fi

if [ "$NEW_VITESS_VERSION" == "" ]; then
echo "Set the env var NEW_VITESS_VERSION with the newest version of Vitess"
exit 1
fi

if [ "$NEW_OPERATOR_VERSION" == "" ]; then
echo "Set the env var NEW_OPERATOR_VERSION with the new version of the operator."
exit 1
fi

if [ "$NEXT_OPERATOR_VERSION" == "" ]; then
echo "Set the env var NEXT_OPERATOR_VERSION with the next dev version version of the operator."
exit 1
fi


function updateVitessImages() {
old_vitess_version=$1
new_vitess_version=$2
new_operator_version=$3

operator_files=$(find -E $ROOT/test/endtoend/operator/* -name "*.yaml" | grep -v "101_initial_cluster.yaml")
sed -i.bak -E "s/vitess\/lite:(.*)/vitess\/lite:v$new_vitess_version/g" $operator_files
sed -i.bak -E "s/vitess\/vtadmin:(.*)/vitess\/vtadmin:v$new_vitess_version/g" $operator_files
sed -i.bak -E "s/vitess\/lite:(.*)/vitess\/lite:v$new_vitess_version\"/g" $ROOT/pkg/apis/planetscale/v2/defaults.go
sed -i.bak -E "s/vitess\/lite:(.*)/vitess\/lite:v$old_vitess_version/g" $ROOT/test/endtoend/operator/101_initial_cluster.yaml
sed -i.bak -E "s/planetscale\/vitess-operator:(.*)/planetscale\/vitess-operator:v$new_operator_version/g" $ROOT/test/endtoend/operator/operator.yaml

rm -f $(find -E $ROOT/test/endtoend/operator/ -name "*.yaml.bak") $ROOT/pkg/apis/planetscale/v2/defaults.go.bak $ROOT/test/endtoend/operator/operator.yaml.bak
}

function updateVersion() {
version=$1

sed -i.bak -E "s/Version = \"(.*)\"/Version = \"$version\"/g" $ROOT/version/version.go
rm -f $ROOT/version/version.go.bak
}


git_status_output=$(git status --porcelain)
if [ "$git_status_output" == "" ]; then
echo so much clean
else
echo "cannot do release with dirty git state"
exit 1
fi

updateVersion $NEW_OPERATOR_VERSION
updateVitessImages $OLD_VITESS_VERSION $NEW_VITESS_VERSION $NEW_OPERATOR_VERSION

git add --all
git commit -n -s -m "Release commit for $NEW_OPERATOR_VERSION"
git tag -m Version\ $NEW_OPERATOR_VERSION v$NEW_OPERATOR_VERSION

updateVersion $NEXT_OPERATOR_VERSION

git add --all
git commit -n -s -m "Back to dev mode"