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.

74 lines
2.4 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 tag "$VERSION" &&
  32. git push --tags >/dev/null 2>/dev/null; } ||
  33. { echo -e "Cannot push released tag into remote repository\n" &&
  34. exit 1; }
  35. else
  36. VERSION=$VERSION_PREVIOUS
  37. fi
  38. git push > /dev/null || exit 1
  39. MESSAGE="\nUpdate ${PATH_LIB} on ${VERSION}\n"
  40. CURRENT_DIR=`pwd`
  41. for project in "${PROJECTS[@]}"
  42. do
  43. echo -e "Update lib for ${project}...\n"
  44. {cd "${project}${PATH_LIB}" &&
  45. git fetch >/dev/null 2>/dev/null &&
  46. git checkout $VERSION 2>/dev/null; } ||
  47. { echo -e "Failed to checkout lib on tag ${VERSION}\n" &&
  48. exit 1; }
  49. cd "${project}"
  50. LIB_DIR=`echo ${PATH_LIB#'/'}`
  51. git diff-index --quiet HEAD "$LIB_DIR"
  52. LIB_NEW_COMMITS=`echo $?`
  53. if [ $LIB_NEW_COMMITS == 1 ]
  54. then
  55. { git reset > /dev/null &&
  56. git add "$LIB_DIR" > /dev/null &&
  57. git commit -m "$MESSAGE" > /dev/null; } ||
  58. { echo -e "Failed to update lib for ${project}\n" &&
  59. exit 1; }
  60. if [ $project == "/var/www/d753_common" ]
  61. then
  62. { git push origin master > /dev/null &&
  63. cd /var/www/d753/ && ./merge-from-master.sh > /dev/null
  64. cd /var/www/d753_10ballov/ && ./merge-from-master.sh > /dev/null; } ||
  65. { echo -e "Failed to update dependency d753 branches... Please resolve that problem by hand\n" &&
  66. exit 1; }
  67. fi
  68. else
  69. echo -e "Already update\n"
  70. fi
  71. done
  72. echo -e "All operations succeed\n"
  73. exit 0