Commit d7e1770e authored by Daniel Agar's avatar Daniel Agar

android set versionCode from git describe

-we need a monotonically increasing integer for android versionCode and
this works better across multiple branches
parent 42b7b9f1
<?xml version="1.0"?>
<manifest package="org.mavlink.qgroundcontrol" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="3.0.0" android:versionCode="2970" android:installLocation="auto">
<manifest package="org.mavlink.qgroundcontrol" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="3.0.1" android:versionCode="301000" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qgroundcontrol.qgchelper.UsbDeviceJNI" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="sensorLandscape" android:launchMode="singleTask" android:keepScreenOn="true">
<intent-filter>
......
#!/usr/bin/env bash
# this requires `origin/master` in the git tree
MANIFEST_FILE=android/AndroidManifest.xml
VERSIONCODE=`git rev-list origin/master --first-parent --count`
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
if [ -n "$VERSIONCODE" ]; then
sed -i -e "s/android:versionCode=\"[0-9][0-9]*\"/android:versionCode=\"$VERSIONCODE\"/" $MANIFEST_FILE
echo "Android version: ${VERSIONCODE}"
......@@ -22,3 +25,4 @@ else
echo "Error versionName empty"
exit 0 # don't cause the build to fail
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment