blob: 1a9fa7e9f1beac6fb0386bbbdf3720ff6e926317 [file] [log] [blame]
#!/bin/bash -e
if [ "$1" == "" ] || [ "$2" == "" ]
echo "Gerrit Code Review - release automation script"
echo "----------------------------------------------"
echo "Use: $0 <branch> <version> <next-version>"
echo ""
echo "Where: branch Gerrit branch name where the release must be cut"
echo " version Gerrit semantic release number"
echo " next-version Next SNAPSHOT version after release"
echo ""
echo "Example: $0 stable-2.16 2.16.7 2.16.8-SNAPSHOT"
exit 1
export branch=$1
export version=$2
export nextversion=$3
if [ -d gerrit ]
rm -Rf gerrit
echo "Cloning and building Gerrit Code Review on branch $branch ..."
git clone && (cd gerrit && f=$(git rev-parse --git-dir)/hooks/commit-msg ; curl -Lo "$f" ; chmod +x "$f")
pushd gerrit
git checkout "$branch"
git fetch && git reset --hard origin/"$branch"
git submodule update --init
git clean -fdx
./tools/ "$version"
git commit -a -m "Set version to $version"
git push origin HEAD:refs/for/"$branch"
git tag -f -s -m "v$version" "v$version"
git submodule foreach 'if [ "$path" != "modules/jgit" ]; then git tag -f -s -m "v$version" "v$version"; fi'
bazelisk build release Documentation:searchfree
./tools/maven/ install
echo -n "Checking Gerrit version ... "
warVersion=$(java -jar bazel-bin/release.war --version)
if ! [ "$warVersion" == "gerrit version $version" ]
echo "Version build is $warVersion but was expecting $version"
exit 2
echo "OK"
echo "Checking Gerrit plugins version ... "
java -jar bazel-bin/release.war init --list-plugins
echo "Publishing Gerrit WAR and APIs to Maven Central ..."
export VERBOSE=1
./tools/maven/ war_deploy
./tools/maven/ deploy
echo "Download the artifacts from SonaType staging repository at"
echo "logging in using your credentials"
cp -f gerrit/bazel-bin/Documentation/ .
cp -f gerrit/bazel-bin/release.war gerrit-"$version".war
echo "gerrit.war checksums"
shasum gerrit-"$version".war
shasum -a 256 gerrit-"$version".war
md5sum gerrit-"$version".war
echo "Pushing to Google Cloud Buckets"
gcloud auth login
echo "Pushing gerrit.war to gerrit-releases ..."
gsutil cp gerrit-"$version".war gs://gerrit-releases/gerrit-"$version".war
echo "Pushing gerrit documentation to gerrit-documentation ..."
pushd Documentation
version_no_rc=$(echo "%version" | cut -d '-' -f 1)
gsutil cp -r . gs://gerrit-documentation/Documentation/"$version_no_rc"
echo "Setting next version tag to $nextversion ..."
pushd gerrit
git clean -fdx
./tools/ "$nextversion"
git commit -a -m "Set version to $nextversion"
git push origin HEAD:refs/for/"$branch"
echo "Release completed"