Created
September 28, 2018 08:03
-
-
Save martinschneider/c205cbfb159abfe46d2361b00337bc5d to your computer and use it in GitHub Desktop.
Revisions
-
martinschneider created this gist
Sep 28, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ #/bin/bash # # Extract the app version number from an APK/IPA file (on Linux) # # Required tools: aapt, plistutil, xmllint # # Usage: # ------ # getAppVersion.sh android pathToApk # getAppVersion.sh ios pathToIpa AppName.app if [ ${1} = 'android' ]; then versionName=$(aapt dump badging ${2} | grep -o 'versionName=[^,]*'| cut -d'=' -f 2 | cut -d ' ' -f 1 | tr -d \') versionCode=$(aapt dump badging ${2} | grep -o 'versionCode=[^,]*'| cut -d'=' -f 2 | cut -d ' ' -f 1 | tr -d \') elif [ ${1} = 'ios' ]; then yes | unzip ${2} versionName=$(plistutil -i Payload/${3}/Info.plist | xmllint --xpath "//key[text()='CFBundleShortVersionString']/following-sibling::string[1]/text()" -) versionCode=$(plistutil -i Payload/${3}/Info.plist | xmllint --xpath "//key[text()='CFBundleVersion']/following-sibling::string[1]/text()" -) fi echo $versionName $versionCode