-
-
Save Voronenko/232ac2343ef6ab75b9da2483880bc7ff to your computer and use it in GitHub Desktop.
Bash script to extract version information from APK and IPA files
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 characters
#/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment