22.add-suffix-to-app-version.bash 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. set -e
  2. # export versionSuffix='.1234.preview'
  3. # bash 22.add-suffix-to-app-version.bash
  4. #---------------------------------------------------------------------
  5. # args
  6. args_="
  7. export versionSuffix=' '
  8. # "
  9. # remove spaces
  10. versionSuffix=${versionSuffix// /}
  11. #----------------------------------------------
  12. # basePath
  13. if [ -z "$basePath" ]; then basePath=$PWD/../../..; fi
  14. #----------------------------------------------
  15. echo "#1 get appVersion"
  16. # get csproj file with appVersion tag, if not exist get file with pack or publish tag
  17. csprojPath=$(find ${basePath} -name *.csproj -exec grep '<appVersion>' -l {} \; | head -n 1);
  18. if [ ! -f "$csprojPath" ]; then csprojPath=$(find ${basePath} -name *.csproj -exec grep '<pack>\|<publish>' -l {} \; | head -n 1); fi
  19. if [ -f "$csprojPath" ]; then export appVersion=`grep '<Version>' "$csprojPath" | grep -oE '\>(.*)\<' | tr -d '<>/'`; fi
  20. echo "appVersion from csproj: $appVersion"
  21. export nextAppVersion="${appVersion}${versionSuffix}"
  22. echo "nextAppVersion: $nextAppVersion"
  23. #----------------------------------------------
  24. echo "#2 change app version from [$appVersion] to [$nextAppVersion]"
  25. sed -i 's/'"$appVersion"'/'"$nextAppVersion"'/g' `find ${basePath} -name *.csproj -exec grep '<pack>\|<publish>' -l {} \;`