-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #308 from planetscale/do-release-automation
Addition of the release automation script
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |