Luca Milanesio | aebf3de | 2018-12-07 22:40:35 +0000 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | |
| 3 | if [ "$1" == "" ] || [ "$2" == "" ] |
| 4 | then |
| 5 | echo "Gerrit Code Review - release automation script" |
| 6 | echo "----------------------------------------------" |
Luca Milanesio | a7ed688 | 2019-03-14 10:47:21 +0000 | [diff] [blame] | 7 | echo "Use: $0 <branch> <version> <next-version>" |
Luca Milanesio | aebf3de | 2018-12-07 22:40:35 +0000 | [diff] [blame] | 8 | echo "" |
| 9 | echo "Where: branch Gerrit branch name where the release must be cut" |
| 10 | echo " version Gerrit semantic release number" |
Luca Milanesio | a7ed688 | 2019-03-14 10:47:21 +0000 | [diff] [blame] | 11 | echo " next-version Next SNAPSHOT version after release" |
Luca Milanesio | aebf3de | 2018-12-07 22:40:35 +0000 | [diff] [blame] | 12 | echo "" |
Luca Milanesio | a7ed688 | 2019-03-14 10:47:21 +0000 | [diff] [blame] | 13 | echo "Example: $0 stable-2.16 2.16.7 2.16.8-SNAPSHOT" |
Luca Milanesio | aebf3de | 2018-12-07 22:40:35 +0000 | [diff] [blame] | 14 | exit 1 |
| 15 | fi |
| 16 | |
| 17 | export branch=$1 |
| 18 | export version=$2 |
Luca Milanesio | a7ed688 | 2019-03-14 10:47:21 +0000 | [diff] [blame] | 19 | export nextversion=$3 |
Luca Milanesio | aebf3de | 2018-12-07 22:40:35 +0000 | [diff] [blame] | 20 | |
| 21 | if [ -d gerrit ] |
| 22 | then |
| 23 | rm -Rf gerrit |
| 24 | fi |
| 25 | |
| 26 | echo "Cloning and building Gerrit Code Review on branch $branch ..." |
Marco Miller | 35241a4 | 2020-10-26 12:13:51 -0400 | [diff] [blame] | 27 | git 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 Milanesio | fed4318 | 2019-01-24 17:11:20 +0000 | [diff] [blame] | 28 | |
Luca Milanesio | aebf3de | 2018-12-07 22:40:35 +0000 | [diff] [blame] | 29 | pushd gerrit |
| 30 | |
Marco Miller | 35241a4 | 2020-10-26 12:13:51 -0400 | [diff] [blame] | 31 | git checkout "$branch" |
| 32 | git fetch && git reset --hard origin/"$branch" |
Luca Milanesio | aebf3de | 2018-12-07 22:40:35 +0000 | [diff] [blame] | 33 | git submodule update --init |
| 34 | |
| 35 | git clean -fdx |
Marco Miller | 35241a4 | 2020-10-26 12:13:51 -0400 | [diff] [blame] | 36 | ./tools/version.py "$version" |
Luca Milanesio | aebf3de | 2018-12-07 22:40:35 +0000 | [diff] [blame] | 37 | git commit -a -m "Set version to $version" |
Marco Miller | 35241a4 | 2020-10-26 12:13:51 -0400 | [diff] [blame] | 38 | git push origin HEAD:refs/for/"$branch" |
Luca Milanesio | a7ed688 | 2019-03-14 10:47:21 +0000 | [diff] [blame] | 39 | |
Luca Milanesio | aebf3de | 2018-12-07 22:40:35 +0000 | [diff] [blame] | 40 | git tag -f -s -m "v$version" "v$version" |
Luca Milanesio | 8f26afd | 2020-05-18 13:16:46 +0100 | [diff] [blame] | 41 | git submodule foreach 'if [ "$path" != "modules/jgit" ]; then git tag -f -s -m "v$version" "v$version"; fi' |
Luca Milanesio | aebf3de | 2018-12-07 22:40:35 +0000 | [diff] [blame] | 42 | |
Luca Milanesio | ddfb973 | 2019-09-20 22:07:37 +0200 | [diff] [blame] | 43 | bazelisk build release Documentation:searchfree |
Luca Milanesio | aebf3de | 2018-12-07 22:40:35 +0000 | [diff] [blame] | 44 | ./tools/maven/api.sh install |
| 45 | |
| 46 | echo -n "Checking Gerrit version ... " |
| 47 | |
| 48 | warVersion=$(java -jar bazel-bin/release.war --version) |
| 49 | |
| 50 | if ! [ "$warVersion" == "gerrit version $version" ] |
| 51 | then |
| 52 | echo "Version build is $warVersion but was expecting $version" |
| 53 | exit 2 |
| 54 | fi |
| 55 | |
| 56 | echo "OK" |
| 57 | |
| 58 | echo "Checking Gerrit plugins version ... " |
| 59 | java -jar bazel-bin/release.war init --list-plugins |
| 60 | |
| 61 | echo "Publishing Gerrit WAR and APIs to Maven Central ..." |
| 62 | export VERBOSE=1 |
| 63 | ./tools/maven/api.sh war_deploy |
| 64 | ./tools/maven/api.sh deploy |
| 65 | |
Luca Milanesio | aebf3de | 2018-12-07 22:40:35 +0000 | [diff] [blame] | 66 | echo "Download the artifacts from SonaType staging repository at https://oss.sonatype.org" |
| 67 | echo "logging in using your credentials" |
Luca Milanesio | 412aafe | 2019-01-24 17:13:28 +0000 | [diff] [blame] | 68 | |
| 69 | popd |
| 70 | |
| 71 | cp -f gerrit/bazel-bin/Documentation/searchfree.zip . |
Marco Miller | 35241a4 | 2020-10-26 12:13:51 -0400 | [diff] [blame] | 72 | cp -f gerrit/bazel-bin/release.war gerrit-"$version".war |
Luca Milanesio | 412aafe | 2019-01-24 17:13:28 +0000 | [diff] [blame] | 73 | |
| 74 | echo "gerrit.war checksums" |
Marco Miller | 35241a4 | 2020-10-26 12:13:51 -0400 | [diff] [blame] | 75 | shasum gerrit-"$version".war |
| 76 | shasum -a 256 gerrit-"$version".war |
| 77 | md5sum gerrit-"$version".war |
Luca Milanesio | 412aafe | 2019-01-24 17:13:28 +0000 | [diff] [blame] | 78 | |
| 79 | echo "Pushing to Google Cloud Buckets" |
| 80 | gcloud auth login |
| 81 | |
| 82 | echo "Pushing gerrit.war to gerrit-releases ..." |
Marco Miller | 35241a4 | 2020-10-26 12:13:51 -0400 | [diff] [blame] | 83 | gsutil cp gerrit-"$version".war gs://gerrit-releases/gerrit-"$version".war |
Luca Milanesio | 412aafe | 2019-01-24 17:13:28 +0000 | [diff] [blame] | 84 | |
| 85 | echo "Pushing gerrit documentation to gerrit-documentation ..." |
| 86 | unzip searchfree.zip |
| 87 | pushd Documentation |
Luca Milanesio | cfc311b | 2020-05-18 17:37:53 +0100 | [diff] [blame] | 88 | version_no_rc=$(echo "%version" | cut -d '-' -f 1) |
Marco Miller | 35241a4 | 2020-10-26 12:13:51 -0400 | [diff] [blame] | 89 | gsutil cp -r . gs://gerrit-documentation/Documentation/"$version_no_rc" |
Luca Milanesio | a7ed688 | 2019-03-14 10:47:21 +0000 | [diff] [blame] | 90 | popd |
| 91 | |
| 92 | echo "Setting next version tag to $nextversion ..." |
| 93 | pushd gerrit |
| 94 | git clean -fdx |
Marco Miller | 35241a4 | 2020-10-26 12:13:51 -0400 | [diff] [blame] | 95 | ./tools/version.py "$nextversion" |
Luca Milanesio | a7ed688 | 2019-03-14 10:47:21 +0000 | [diff] [blame] | 96 | git commit -a -m "Set version to $nextversion" |
Marco Miller | 35241a4 | 2020-10-26 12:13:51 -0400 | [diff] [blame] | 97 | git push origin HEAD:refs/for/"$branch" |
Luca Milanesio | a7ed688 | 2019-03-14 10:47:21 +0000 | [diff] [blame] | 98 | popd |
Luca Milanesio | 412aafe | 2019-01-24 17:13:28 +0000 | [diff] [blame] | 99 | |
| 100 | echo "Release completed" |