blob: 1a9fa7e9f1beac6fb0386bbbdf3720ff6e926317 [file] [log] [blame]
Luca Milanesioaebf3de2018-12-07 22:40:35 +00001#!/bin/bash -e
2
3if [ "$1" == "" ] || [ "$2" == "" ]
4then
5 echo "Gerrit Code Review - release automation script"
6 echo "----------------------------------------------"
Luca Milanesioa7ed6882019-03-14 10:47:21 +00007 echo "Use: $0 <branch> <version> <next-version>"
Luca Milanesioaebf3de2018-12-07 22:40:35 +00008 echo ""
9 echo "Where: branch Gerrit branch name where the release must be cut"
10 echo " version Gerrit semantic release number"
Luca Milanesioa7ed6882019-03-14 10:47:21 +000011 echo " next-version Next SNAPSHOT version after release"
Luca Milanesioaebf3de2018-12-07 22:40:35 +000012 echo ""
Luca Milanesioa7ed6882019-03-14 10:47:21 +000013 echo "Example: $0 stable-2.16 2.16.7 2.16.8-SNAPSHOT"
Luca Milanesioaebf3de2018-12-07 22:40:35 +000014 exit 1
15fi
16
17export branch=$1
18export version=$2
Luca Milanesioa7ed6882019-03-14 10:47:21 +000019export nextversion=$3
Luca Milanesioaebf3de2018-12-07 22:40:35 +000020
21if [ -d gerrit ]
22then
23 rm -Rf gerrit
24fi
25
26echo "Cloning and building Gerrit Code Review on branch $branch ..."
Marco Miller35241a42020-10-26 12:13:51 -040027git clone https://gerrit.googlesource.com/gerrit && (cd gerrit && f=$(git rev-parse --git-dir)/hooks/commit-msg ; curl -Lo "$f" https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; chmod +x "$f")
Luca Milanesiofed43182019-01-24 17:11:20 +000028
Luca Milanesioaebf3de2018-12-07 22:40:35 +000029pushd gerrit
30
Marco Miller35241a42020-10-26 12:13:51 -040031git checkout "$branch"
32git fetch && git reset --hard origin/"$branch"
Luca Milanesioaebf3de2018-12-07 22:40:35 +000033git submodule update --init
34
35git clean -fdx
Marco Miller35241a42020-10-26 12:13:51 -040036./tools/version.py "$version"
Luca Milanesioaebf3de2018-12-07 22:40:35 +000037git commit -a -m "Set version to $version"
Marco Miller35241a42020-10-26 12:13:51 -040038git push origin HEAD:refs/for/"$branch"
Luca Milanesioa7ed6882019-03-14 10:47:21 +000039
Luca Milanesioaebf3de2018-12-07 22:40:35 +000040git tag -f -s -m "v$version" "v$version"
Luca Milanesio8f26afd2020-05-18 13:16:46 +010041git submodule foreach 'if [ "$path" != "modules/jgit" ]; then git tag -f -s -m "v$version" "v$version"; fi'
Luca Milanesioaebf3de2018-12-07 22:40:35 +000042
Luca Milanesioddfb9732019-09-20 22:07:37 +020043bazelisk build release Documentation:searchfree
Luca Milanesioaebf3de2018-12-07 22:40:35 +000044./tools/maven/api.sh install
45
46echo -n "Checking Gerrit version ... "
47
48warVersion=$(java -jar bazel-bin/release.war --version)
49
50if ! [ "$warVersion" == "gerrit version $version" ]
51then
52 echo "Version build is $warVersion but was expecting $version"
53 exit 2
54fi
55
56echo "OK"
57
58echo "Checking Gerrit plugins version ... "
59java -jar bazel-bin/release.war init --list-plugins
60
61echo "Publishing Gerrit WAR and APIs to Maven Central ..."
62export VERBOSE=1
63./tools/maven/api.sh war_deploy
64./tools/maven/api.sh deploy
65
Luca Milanesioaebf3de2018-12-07 22:40:35 +000066echo "Download the artifacts from SonaType staging repository at https://oss.sonatype.org"
67echo "logging in using your credentials"
Luca Milanesio412aafe2019-01-24 17:13:28 +000068
69popd
70
71cp -f gerrit/bazel-bin/Documentation/searchfree.zip .
Marco Miller35241a42020-10-26 12:13:51 -040072cp -f gerrit/bazel-bin/release.war gerrit-"$version".war
Luca Milanesio412aafe2019-01-24 17:13:28 +000073
74echo "gerrit.war checksums"
Marco Miller35241a42020-10-26 12:13:51 -040075shasum gerrit-"$version".war
76shasum -a 256 gerrit-"$version".war
77md5sum gerrit-"$version".war
Luca Milanesio412aafe2019-01-24 17:13:28 +000078
79echo "Pushing to Google Cloud Buckets"
80gcloud auth login
81
82echo "Pushing gerrit.war to gerrit-releases ..."
Marco Miller35241a42020-10-26 12:13:51 -040083gsutil cp gerrit-"$version".war gs://gerrit-releases/gerrit-"$version".war
Luca Milanesio412aafe2019-01-24 17:13:28 +000084
85echo "Pushing gerrit documentation to gerrit-documentation ..."
86unzip searchfree.zip
87pushd Documentation
Luca Milanesiocfc311b2020-05-18 17:37:53 +010088version_no_rc=$(echo "%version" | cut -d '-' -f 1)
Marco Miller35241a42020-10-26 12:13:51 -040089gsutil cp -r . gs://gerrit-documentation/Documentation/"$version_no_rc"
Luca Milanesioa7ed6882019-03-14 10:47:21 +000090popd
91
92echo "Setting next version tag to $nextversion ..."
93pushd gerrit
94git clean -fdx
Marco Miller35241a42020-10-26 12:13:51 -040095./tools/version.py "$nextversion"
Luca Milanesioa7ed6882019-03-14 10:47:21 +000096git commit -a -m "Set version to $nextversion"
Marco Miller35241a42020-10-26 12:13:51 -040097git push origin HEAD:refs/for/"$branch"
Luca Milanesioa7ed6882019-03-14 10:47:21 +000098popd
Luca Milanesio412aafe2019-01-24 17:13:28 +000099
100echo "Release completed"