Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. # The following is test script to execute in pre build process
  2.  
  3. #!/usr/bin/env bash
  4. #
  5. # For Xamarin Android or iOS, change the package name located in AndroidManifest.xml and Info.plist.
  6. # AN IMPORTANT THING: YOU NEED DECLARE BASE_URL, SECRET and TEST_COLOR ENVIRONMENT VARIABLE IN APP CENTER BUILD CONFIGURATION.
  7.  
  8. # This path will vary depending upon your project structure
  9. ANDROID_MANIFEST_FILE=$APPCENTER_SOURCE_DIRECTORY/MyWeatherApp/MyWeatherApp.Android/Properties/AndroidManifest.xml
  10.  
  11. if [ ! -n "$ANDROID_MANIFEST_FILE" ]
  12. then
  13. echo "You need define AndroidManifest.xml in your Android project"
  14. exit
  15. fi
  16.  
  17. echo "APPCENTER_SOURCE_DIRECTORY: " $APPCENTER_SOURCE_DIRECTORY
  18. echo "ANDROID_MANIFEST_FILE: " $ANDROID_MANIFEST_FILE
  19.  
  20. # Check branch and run commands if so:
  21. if [ "$APPCENTER_BRANCH" == "master" ]; then
  22.  
  23. VERSIONCODE=`grep versionCode $ANDROID_MANIFEST_FILE | sed 's/.*versionCode="//;s/".*//'`
  24. VERSIONNAME=`grep versionName $ANDROID_MANIFEST_FILE | sed 's/.*versionName="//;s/".*//'`
  25.  
  26. echo "Current VersionCode: " $VERSIONCODE
  27. echo "Current VersionName: " $VERSIONNAME
  28.  
  29. # Actually increment the version in this line
  30. UPDATED_VERSIONNAME=$(bc <<< "$VERSIONNAME + 0.1")
  31.  
  32. echo "Updating versionCode to $APPCENTER_BUILD_ID and versionName to $UPDATED_VERSIONNAME in AndroidManifest.xml"
  33. sed -i '' 's/versionCode="[0-9.]*"/versionCode="'$APPCENTER_BUILD_ID'"/; s/versionName *= *"[^"]*"/versionName="'$UPDATED_VERSIONNAME'"/' $ANDROID_MANIFEST_FILE
  34.  
  35. fi
  36.  
  37. if [ "$APPCENTER_BRANCH" == "staging" ]; then
  38.  
  39. VERSIONCODE=`grep versionCode $ANDROID_MANIFEST_FILE | sed 's/.*versionCode="//;s/".*//'`
  40. VERSIONNAME=`grep versionName $ANDROID_MANIFEST_FILE | sed 's/.*versionName="//;s/".*//'`
  41.  
  42. # Print the values
  43. echo "Current VersionCode: " $VERSIONCODE
  44. echo "Current VersionName: " $VERSIONNAME
  45.  
  46. fi
  47.  
  48. echo "Manifest file content:"
  49. cat $ANDROID_MANIFEST_FILE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement