tools/release.sh: Simplify our release build process

Rather than having 3 commands for a human to type in by hand,
lets wrap it all up into a tiny shell script.

Change-Id: I967416266e7cde3a2a5ae567bdc4524c874b4a34
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce 2009-12-18 14:47:55 -08:00
parent 4b5e95f8ae
commit d46db64b4c
3 changed files with 35 additions and 21 deletions

View File

@ -129,24 +129,9 @@ To create a release build for a production server, or deployment
through the download site:
----
./tools/version.sh --release
mvn clean package
git reset --hard
./tools/release.sh
----
The first script, 'tools/version.sh' updates the pom.xml files with
the current build number from Git, so the version appears in the
embedded JAR file names, and in the final WAR file name.
A clean build is necesary to ensure different versions of the
same dependency don't wind up in the output WAR. If a dependency
changes versions, Maven often leaves the old version in the WAR,
and also includes the new version, resulting in an ambiguous class
loading order at runtime.
The final command replaces all modified files with their last
committed revisions, undoing the edits made by 'tools/version.sh'.
Client-Server RPC
-----------------

24
tools/release.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
git update-index -q --refresh
if test -n "$(git diff-index --name-only HEAD --)" \
|| test -n "$(git ls-files --others --exclude-standard)"
then
echo >&2 "error: working directory is dirty, refusing to build"
exit 1
fi
./tools/version.sh --release &&
mvn clean package
rc=$?
./tools/version.sh --reset
if test 0 = $rc
then
echo
echo Built Gerrit Code Review `git describe`:
ls gerrit-war/target/gerrit-*.war
echo
fi
exit $rc

View File

@ -6,6 +6,8 @@
# Java based Maven plugin so its fully portable.
#
POM_FILES=$(git ls-files | grep pom.xml)
case "$1" in
--snapshot=*)
V=$(echo "$1" | perl -pe 's/^--snapshot=//')
@ -24,8 +26,13 @@ case "$1" in
V=$(git describe HEAD) || exit
;;
--reset)
git checkout HEAD -- $POM_FILES
exit $?
;;
*)
echo >&2 "usage: $0 {--snapshot=0.n.0 | --release}"
echo >&2 "usage: $0 {--snapshot=2.n | --release}"
exit 1
esac
@ -40,8 +47,6 @@ perl -pi -e '
}
if (!$seen_version) {
$seen_version = 1 if
s{(<version>).*(</version>)}{${1}'"$POM_V"'${2}};
s{(<version>).*(</version>)}{${1}'"$V"'${2}};
}
' $(git ls-files | grep pom.xml)
git diff
' $POM_FILES