21.change-to-next-version.bash 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. set -e
  2. # export versionSuffix='.1234.preview'
  3. # bash 21.change-to-next-version.bash
  4. #---------------------------------------------------------------------
  5. #(x.1)参数
  6. args_="
  7. export versionSuffix=''
  8. # "
  9. #----------------------------------------------
  10. #(x.2)当前路径
  11. curPath=$PWD
  12. cd $curPath/../../..
  13. export basePath=$PWD
  14. cd $curPath
  15. #----------------------------------------------
  16. echo "#1 get version"
  17. export version=`grep '<Version>' $(find ${basePath} -name *.csproj -exec grep '<pack>\|<publish>' -l {} \; | head -n 1) | grep -oE '\>(.*)\<' | tr -d '<>/'`
  18. echo "version from csproj: $version"
  19. # get v1 v2 v3
  20. v1=$(echo $version | tr '.' '\n' | sed -n 1p)
  21. v2=$(echo $version | tr '.' '\n' | sed -n 2p)
  22. v3=$(echo $version | tr '.-' '\n' | sed -n 3p)
  23. ((v3++));
  24. export appVersion="$v1.$v2.$v3$versionSuffix"
  25. echo "appVersion: $appVersion"
  26. #----------------------------------------------
  27. echo "#2 change app version from [$version] to [$appVersion]"
  28. sed -i 's/'"$version"'/'"$appVersion"'/g' `find ${basePath} -name *.csproj -exec grep '<pack>\|<publish>' -l {} \;`
  29. #----------------------------------------------
  30. #9
  31. cd $curPath