update_android_version.sh 779 Bytes
Newer Older
Lorenz Meier's avatar
Lorenz Meier committed
1
#!/usr/bin/env bash
2

3 4 5
# this requires `master` in the git tree
#  travis-ci branch builds are unable to set the version properly

6 7
MANIFEST_FILE=android/AndroidManifest.xml

8 9 10
VERSIONCODE=`git rev-list master --first-parent --count`
VERSIONNAME=`git describe --always --tags | sed -e 's/^v//'`

11 12
if [ -n "$VERSIONCODE" ]; then
	sed -i -e "s/android:versionCode=\"[0-9][0-9]*\"/android:versionCode=\"$VERSIONCODE\"/" $MANIFEST_FILE
Lorenz Meier's avatar
Lorenz Meier committed
13
	echo "Android version: ${VERSIONCODE}"
14 15
else
	echo "Error versionCode empty"
16
	exit 0 # don't cause the build to fail
17 18 19 20
fi

if [ -n "$VERSIONNAME" ]; then
	sed -i -e 's/versionName *= *"[^"]*"/versionName="'$VERSIONNAME'"/' $MANIFEST_FILE
Lorenz Meier's avatar
Lorenz Meier committed
21
	echo "Android name: ${VERSIONNAME}"
22 23
else
	echo "Error versionName empty"
24
	exit 0 # don't cause the build to fail
25
fi