From d759437ee505ce2cc97b9d61342f87c77cab66f8 Mon Sep 17 00:00:00 2001 From: Daniel Agar <daniel@agar.ca> Date: Tue, 13 Sep 2016 20:52:39 -0400 Subject: [PATCH] android set versionCode from git describe -we need a monotonically increasing integer for android versionCode and this works better across multiple branches --- android/AndroidManifest.xml | 2 +- tools/update_android_version.sh | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 00e46a6784..fe4815802b 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,5 +1,5 @@ <?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="2976" android:installLocation="auto"> +<manifest package="org.mavlink.qgroundcontrol" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="3.0.0-243-gcd69981" android:versionCode="3.0.0.243-gcd69981" 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> diff --git a/tools/update_android_version.sh b/tools/update_android_version.sh index 4211dc9823..7b98cca2a8 100755 --- a/tools/update_android_version.sh +++ b/tools/update_android_version.sh @@ -1,17 +1,15 @@ #!/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//'` -# increment the versionCode past master for tagged releases -if [ "${TRAVIS_TAG}" ]; then - let VERSIONCODE=${VERSIONCODE}+1 -fi +# 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}" @@ -27,3 +25,4 @@ else echo "Error versionName empty" exit 0 # don't cause the build to fail fi + -- GitLab