xwords/xwords4/android/scripts/arelease_clone.sh
Andy2 57838c0436 improve script. Allow pass either branch or tag on commandline,
defaulting to branch of tree from which called.  Add usage().  set -u
-e and deal with [ -n "$1" ] being an error in that case.
2010-11-07 08:16:36 -08:00

56 lines
936 B
Bash
Executable file

#!/bin/sh
set -e -u
usage () {
echo "usage: $(basename $0) [--tag tagname | --branch branchname]"
echo " # (uses current branch as default)"
exit 0
}
TAG=""
BRANCH=""
while [ 0 -lt $# ] ; do
case $1 in
--tag)
TAG=$2
shift
;;
--branch)
BRANCH=$2
shift
;;
*)
usage
;;
esac
shift
done
if [ -n "$TAG" ]; then
if ! git tag | grep -w "$TAG"; then
echo "tag $TAG not found"
usage
fi
elif [ -z $BRANCH ]; then
BRANCH=$(git branch | grep '^*' | sed 's,^.* ,,')
fi
echo "building with ${TAG}${BRANCH}"
BUILDIR=/tmp/$(basename $0)_build_$$
SRCDIR=$(pwd)/$(dirname $0)/../../../
CURDIR=$(pwd)
mkdir -p $BUILDIR
cd $BUILDIR
git clone $SRCDIR BUILD
cd BUILD
git checkout ${TAG}${BRANCH}
./xwords4/android/scripts/arelease.sh
cp *.apk /tmp
cd $CURDIR
rm -rf $BUILDIR