Browse Source

android set versionCode from git describe

-we need a monotonically increasing integer for android versionCode and
this works better across multiple branches
QGC4.4
Daniel Agar 9 years ago
parent
commit
d759437ee5
  1. 2
      android/AndroidManifest.xml
  2. 17
      tools/update_android_version.sh

2
android/AndroidManifest.xml

@ -1,5 +1,5 @@
<?xml version="1.0"?> <?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"> <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"> <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> <intent-filter>

17
tools/update_android_version.sh

@ -1,17 +1,15 @@
#!/usr/bin/env bash #!/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//'` VERSIONNAME=`git describe --always --tags | sed -e 's/^v//'`
# increment the versionCode past master for tagged releases # Android versionCode from git tag vX.Y.Z-123-gSHA
if [ "${TRAVIS_TAG}" ]; then IFS=. read major minor patch dev sha <<<"${VERSIONNAME//-/.}"
let VERSIONCODE=${VERSIONCODE}+1 VERSIONCODE=$(($major*100000))
fi VERSIONCODE=$(($(($minor*10000)) + $VERSIONCODE))
VERSIONCODE=$(($(($patch*1000)) + $VERSIONCODE))
VERSIONCODE=$(($(($dev)) + $VERSIONCODE))
MANIFEST_FILE=android/AndroidManifest.xml
if [ -n "$VERSIONCODE" ]; then if [ -n "$VERSIONCODE" ]; then
sed -i -e "s/android:versionCode=\"[0-9][0-9]*\"/android:versionCode=\"$VERSIONCODE\"/" $MANIFEST_FILE sed -i -e "s/android:versionCode=\"[0-9][0-9]*\"/android:versionCode=\"$VERSIONCODE\"/" $MANIFEST_FILE
echo "Android version: ${VERSIONCODE}" echo "Android version: ${VERSIONCODE}"
@ -27,3 +25,4 @@ else
echo "Error versionName empty" echo "Error versionName empty"
exit 0 # don't cause the build to fail exit 0 # don't cause the build to fail
fi fi

Loading…
Cancel
Save