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.

75 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 "Update lib for ${project}...\n"
  43. (cd "${project}${PATH_LIB}" &&
  44. git fetch >/dev/null 2>/dev/null &&
  45. git checkout $VERSION 2>/dev/null) ||
  46. (echo -e "Failed to checkout lib on tag ${VERSION}\n" &&
  47. exit 1)
  48. cd "${project}"
  49. LIB_DIR=`echo ${PATH_LIB#'/'}`
  50. git diff-index --quiet HEAD "$LIB_DIR"
  51. LIB_NEW_COMMITS=`echo $?`
  52. if [ $LIB_NEW_COMMITS == 1 ]
  53. then
  54. echo -e "`pwd`\n"
  55. exit 1
  56. (git reset > /dev/null &&
  57. git add "$LIB_DIR" > /dev/null &&
  58. git commit -m $MESSAGE > /dev/null) ||
  59. (echo -e "Failed to update lib for ${project}\n" &&
  60. exit 1)
  61. if [ $project == "/var/www/d753_common" ]
  62. then
  63. (git push origin master > /dev/null &&
  64. cd /var/www/d753/ && ./merge-from-master.sh > /dev/null
  65. cd /var/www/d753_10ballov/ && ./merge-from-master.sh > /dev/null) ||
  66. (echo -e "Failed to update dependency d753 branches... Please resolve that problem by hand\n" &&
  67. exit 1)
  68. fi
  69. else
  70. echo -e "Already update\n"
  71. fi
  72. done
  73. echo -e "All operations succeed\n"
  74. exit 0