You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.3 KiB

  1. #!/bin/bash
  2. PATH_LIB='/lib/Image'
  3. PROJECTS=( "/var/www/10ballov" "/var/www/predelanet" "/var/www/zelenoemore" "/var/www/d753_common" )
  4. if [ ! -f "CHANGELOG.md" ]
  5. then
  6. echo "CHANGELOG.md not exists\n"
  7. exit 1
  8. fi
  9. test -n "`tail CHANGELOG.md`"
  10. CHANGELOG_EMPTY=`echo $?`
  11. if [ $CHANGELOG_EMPTY == 1 ]
  12. then
  13. echo -e "CHANGELOG.md is empty\n"
  14. exit 1
  15. fi
  16. git diff-index --quiet HEAD --
  17. REPO_CHANGED=`echo $?`
  18. if [ $REPO_CHANGED == 1 ]
  19. then
  20. echo -e "Please commit all changes in repository\n"
  21. exit 1
  22. fi
  23. VERSION_PREVIOUS=`sed -n '4,4p' CHANGELOG.md | cut -d "(" -f1`
  24. if [ `git rev-parse ${VERSION_PREVIOUS}` != `git rev-parse HEAD` ]
  25. then
  26. VERSION=`echo ${VERSION_PREVIOUS} | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}'`
  27. git tag $VERSION &&
  28. gitchangelog > CHANGELOG.md &&
  29. (git add CHANGELOG.md > /dev/null &&
  30. git commit -m 'Update CHANGELOG.md' > /dev/null &&
  31. git push --tags > /dev/null) ||
  32. (echo -e "Cannot push released tag into remote repository\n" &&
  33. exit 1)
  34. else
  35. VERSION=$VERSION_PREVIOUS
  36. fi
  37. git push > /dev/null || exit 1
  38. MESSAGE="\nUpdate ${PATH_LIB} on ${VERSION}\n"
  39. CURRENT_DIR=`pwd`
  40. for project in "${PROJECTS[@]}"
  41. do
  42. echo -e "\nUpdate lib for ${project}...\n"
  43. (cd "${project}${PATH_LIB}" &&
  44. git fetch > /dev/null &&
  45. git checkout $VERSION 2> /dev/null) ||
  46. (echo -e "\nFailed to checkout lib on tag ${VERSION}\n" &&
  47. exit 1)
  48. cd "${project}"
  49. git diff-index --quiet HEAD "`echo ${PATH_LIB#'/'}`"
  50. LIB_NEW_COMMITS=`echo $?`
  51. if [ $LIB_NEW_COMMITS == 1 ]
  52. then
  53. (git reset > /dev/null &&
  54. git add "`echo ${PATH_LIB#'/'}`" > /dev/null &&
  55. git commit -m $MESSAGE > /dev/null) ||
  56. (echo -e "\nFailed to update lib for ${project}\n" &&
  57. exit 1)
  58. if [ $project == "/var/www/d753_common" ]
  59. then
  60. (git push origin master > /dev/null &&
  61. cd /var/www/d753/ && ./merge-from-master.sh > /dev/null
  62. cd /var/www/d753_10ballov/ && ./merge-from-master.sh > /dev/null) ||
  63. (echo -e "\nFailed to update dependency d753 branches... Please resolve that problem by hand\n" &&
  64. exit 1)
  65. fi
  66. else
  67. echo -e "\nAlready update\n"
  68. fi
  69. done
  70. echo -e "\nAll operations succeed\n"
  71. exit 0