gerrit/tools/version.sh
Shawn O. Pearce d46db64b4c 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>
2009-12-18 14:51:07 -08:00

53 lines
843 B
Bash
Executable File

#!/bin/sh
# Update all pom.xml with new build number
#
# TODO(sop) This should be converted to some sort of
# 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=//')
if [ -z "$V" ]
then
echo >&2 "usage: $0 --snapshot=0.n.0"
exit 1
fi
case "$V" in
*-SNAPSHOT) : ;;
*) V=$V-SNAPSHOT ;;
esac
;;
--release)
V=$(git describe HEAD) || exit
;;
--reset)
git checkout HEAD -- $POM_FILES
exit $?
;;
*)
echo >&2 "usage: $0 {--snapshot=2.n | --release}"
exit 1
esac
case "$V" in
v*) V=$(echo "$V" | perl -pe s/^v//) ;;
esac
perl -pi -e '
if ($ARGV ne $old_argv) {
$seen_version = 0;
$old_argv = $ARGV;
}
if (!$seen_version) {
$seen_version = 1 if
s{(<version>).*(</version>)}{${1}'"$V"'${2}};
}
' $POM_FILES