Last active
October 1, 2019 13:34
-
-
Save felipebaltazar/b04f579bd21deae93f97703cd485c572 to your computer and use it in GitHub Desktop.
Version bump for android on AppCenter
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
#!/usr/bin/env bash | |
# | |
#AN IMPORTANT THING: YOU NEED DECLARE VERSION_MAJOR AND VERSION_MINOR ENVIRONMENT VARIABLES IN APP CENTER BUILD CONFIGURATION. | |
echo "==============================================================================" | |
echo "Task : Version bumping" | |
echo "Description : Set the new version on AndroidManifest with current appcenter build id." | |
echo "Version : 1.0.0" | |
echo "Author : Felipe baltazar - Felipe.baltazar@simix.com.br" | |
echo "Help : [More Information](https://github.com/felipebaltazar)" | |
echo "==============================================================================" | |
if [ -z "$VERSION_MAJOR" ] | |
then | |
echo "You need define the VERSION_MAJOR variable in App Center" | |
exit | |
fi | |
if [ -z "$VERSION_MINOR" ] | |
then | |
echo "You need define the VERSION_MINOR variable in App Center" | |
exit | |
fi | |
ANDROID_MANIFEST_FILE=$APPCENTER_SOURCE_DIRECTORY/Droid/Properties/AndroidManifest.xml | |
VERSION_CODE=$VERSION_MAJOR$VERSION_MINOR$BUILD_ID | |
VERSION_NAME="$VERSION_MAJOR.$VERSION_MINOR.$APPCENTER_BUILD_ID" | |
if [ -e "$ANDROID_MANIFEST_FILE" ] | |
then | |
echo "Updating version name to $VERSION_NAME and version code to $VERSION_CODE in AndroidManifest.xml" | |
sed -i -E 's/versionName="[0-9.]*"/versionName="'$VERSION_NAME'"/' $ANDROID_MANIFEST_FILE | |
sed -i -E 's/android:versionCode="[^"]*"/android:versionCode="'$VERSION_CODE'"/' $ANDROID_MANIFEST_FILE | |
echo "File content:" | |
cat $ANDROID_MANIFEST_FILE | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment