1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
VERSIONNAME=`git describe --always --tags | sed -e 's/^v//'`
# Android versionCode from git tag vX.Y.Z-123-gSHA
IFS=. read major minor patch dev sha <<<"${VERSIONNAME//-/.}"
VERSIONCODE=$(($major*100000))
VERSIONCODE=$(($(($minor*10000)) + $VERSIONCODE))
VERSIONCODE=$(($(($patch*1000)) + $VERSIONCODE))
VERSIONCODE=$(($(($dev)) + $VERSIONCODE))
MANIFEST_FILE=android/AndroidManifest.xml
# manifest package
if [ ${#dev} -gt 0 ]; then
QGC_PKG_NAME="org.mavlink.qgroundcontrolbeta"
sed -i -e 's/package *= *"[^"]*"/package="'$QGC_PKG_NAME'"/' $MANIFEST_FILE
echo "Android package name: $QGC_PKG_NAME"
fi
# android:versionCode
if [ -n "$VERSIONCODE" ]; then
sed -i -e "s/android:versionCode=\"[0-9][0-9]*\"/android:versionCode=\"$VERSIONCODE\"/" $MANIFEST_FILE
echo "Android version: ${VERSIONCODE}"
else
echo "Error versionCode empty"
exit 0 # don't cause the build to fail
fi
# android:versionName
if [ -n "$VERSIONNAME" ]; then
sed -i -e 's/versionName *= *"[^"]*"/versionName="'$VERSIONNAME'"/' $MANIFEST_FILE
echo "Android name: ${VERSIONNAME}"
else
echo "Error versionName empty"
exit 0 # don't cause the build to fail
fi