xwords/xwords4/android/scripts/arelease.sh

79 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/bash
2012-01-03 03:11:36 +01:00
set -u -e
TAGNAME=""
FILES=""
LIST_FILE=''
2012-01-03 03:25:01 +01:00
XW_WWW_PATH=${XW_WWW_PATH:-""}
XW_RELEASE_SCP_DEST=${XW_RELEASE_SCP_DEST:-""}
2023-07-01 21:32:04 +02:00
VARIANT=""
2012-01-03 03:11:36 +01:00
usage() {
echo "Error: $*" >&2
echo "usage: $0 [--tag <name>] [--apk-list path/to/out.txt] \\"
2022-08-11 03:18:08 +02:00
echo " --variant <VARIANT> "
echo " [<package-unsigned.apk>]" >&2
2023-07-01 21:32:04 +02:00
echo "Here are some possible variants:"
for VAR in $(./gradlew tasks | grep assembleXw4 | awk '{print $1}' | sed -e 's/assemble//'); do
echo " $VAR"
done
exit 1
}
do_build() {
(cd $(dirname $0)/../ && ./gradlew clean as${VARIANT}Rel)
}
2012-01-03 03:11:36 +01:00
while [ "$#" -gt 0 ]; do
case $1 in
2012-03-02 07:10:41 +01:00
--tag)
TAGNAME=$2
git describe $TAGNAME || usage "$TAGNAME not a valid git tag"
shift
2012-03-02 07:10:41 +01:00
;;
--apk-list)
LIST_FILE=$2
> $LIST_FILE
shift
;;
--variant)
2021-03-26 01:13:21 +01:00
VARIANT=${2^}
shift
;;
--help)
usage
;;
*)
FILES="$1"
;;
esac
shift
done
if [ -n "$TAGNAME" ]; then
git branch 2>/dev/null | grep '\* android_branch' \
|| usage "not currently at android_branch"
git checkout $TAGNAME 2>/dev/null || usage "unable to checkout $TAGNAME"
HASH=$(git log -1 --pretty=format:%H)
CHECK_BRANCH=$(git describe $HASH 2>/dev/null)
if [ "$CHECK_BRANCH" != $TAGNAME ]; then
usage "tagname not found in repo or not as expected"
fi
git stash
fi
2023-07-01 21:32:04 +02:00
if [ -z "$VARIANT" ]; then
usage "--variant not optional"
elif [ -z "$FILES" ]; then
do_build
for f in $(ls $(dirname $0)/../app/build/outputs/apk/*/release/*-release-unsigned-*.apk); do
$(dirname $0)/sign-align.sh --apk $f
done
fi
if [ -n "$TAGNAME" ]; then
git stash pop
git checkout android_branch 2>/dev/null
fi