release.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/bash
  2. pause() {
  3. while true; do
  4. read -p "$1 " yn
  5. case $yn in
  6. [Yy]* ) break;;
  7. [Nn]* ) exit;;
  8. * ) echo "Please answer yes or no.";;
  9. esac
  10. done
  11. }
  12. cd `dirname $0`/..
  13. SOURCE=`pwd`
  14. CUR_VERSION=`node -e 'console.log(require("./package.json").version)'`
  15. git --no-pager log --first-parent --oneline v$CUR_VERSION..master
  16. echo "current version is $CUR_VERSION"
  17. read -p "enter version number for the build " VERSION_NUM
  18. node -e "
  19. var fs = require('fs');
  20. var version = '$VERSION_NUM';
  21. function replaceVersion(str) {
  22. return str.replace(/(['\"]?version['\"]?\s*[:=]\s*['\"])[\\d.\\w\\-]+(['\"])/, function(_, m1, m2) {
  23. return m1 + version + m2;
  24. });
  25. }
  26. function update(path, replace) {
  27. var pkg = fs.readFileSync(path, 'utf8');
  28. pkg = (replace || replaceVersion)(pkg);
  29. fs.writeFileSync(path, pkg, 'utf8');
  30. }
  31. update('package.json');
  32. update('build/package.json');
  33. update('./lib/ace/ext/menu_tools/generate_settings_menu.js');
  34. update('ChangeLog.txt', function(str) {
  35. var date='"`date +%Y.%m.%d`"';
  36. return date + ' Version ' + version + '\n' + str.replace(/^\d+.*/, '').replace(/^\n/, '');
  37. });
  38. "
  39. pause "versions updated. do you want to start build script? [y/n]"
  40. node Makefile.dryice.js full
  41. cd build
  42. git add .
  43. git commit --all -m "package `date +%d.%m.%y`"
  44. echo "build task completed."
  45. pause "continue creating the tag for v$VERSION_NUM [y/n]"
  46. if [[ ${VERSION_NUM} != *"-"* ]]; then
  47. git tag "v"$VERSION_NUM
  48. fi
  49. pause "continue pushing to github? [y/n]"
  50. git push --progress --tags "origin" HEAD:gh-pages HEAD:master
  51. echo "build repository updated"
  52. pause "continue update ace repo? [y/n]"
  53. cd ..
  54. echo "new commit added"
  55. pause "continue creating the tag for v$VERSION_NUM [y/n]"
  56. if [[ ${VERSION_NUM} != *"-"* ]]; then
  57. git tag "v"$VERSION_NUM
  58. fi
  59. pause "continue pushing to github? [y/n]"
  60. git push --progress --tags "origin" HEAD:gh-pages HEAD:master
  61. echo "All done!"
  62. pause "May I go now? [y/n]"