Created
July 14, 2012 15:35
-
-
Save kendellfab/3111850 to your computer and use it in GitHub Desktop.
Bash script for changing version code and version name in an android manifest.
This file contains 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
MANIFEST_FILE='AndroidManifest.xml' | |
VERSIONCODE=`grep versionCode $MANIFEST_FILE | sed 's/.*versionCode="//;s/".*//'` | |
VERSIONNAME=`grep versionName $MANIFEST_FILE | sed 's/.*versionName="//;s/\.[0-9]*".*//'` | |
NEWCODE=$BUILD_NUMBER | |
NEWNAME=$VERSIONNAME.$BUILD_NUMBER | |
echo "Updating Android build information. New version code: $NEWCODE - New version name: $NEWNAME"; | |
sed -i 's/versionCode *= *"'$VERSIONCODE'"/versionCode="'$NEWCODE'"/; s/versionName *= *"[^"]*"/versionName="'$NEWNAME'"/' $MANIFEST_FILE |
You need to change the last line to
sed -i '' 's/versionCode = *"'$VERSIONCODE'"/versionCode="'$NEWCODE'"/; s/versionName *= *"[^"]"/versionName="'$NEWNAME'"/' $MANIFEST_FILE
None of the above sed worked!!
Below is the data/file content
versionName 0.0.3
Expected: versionName 0.0.4
Use command:
sed -ie 's/versionName .*/versionName 0.0.4/' "filename"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case of simpler version
sed -i.bak 's/android:versionName="."/android:versionName="${version_name}"/g' AndroidManifest.xml
sed -i.bak 's/android:versionCode="."/android:versionCode="${BUILD_NUMBER}"/g' AndroidManifest.xml