release.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. VERSION_NUM=;
  18. until [[ "$VERSION_NUM" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] ; do
  19. read -p "enter version number for the build " VERSION_NUM
  20. done
  21. node -e "
  22. var fs = require('fs');
  23. var version = '$VERSION_NUM';
  24. function replaceVersion(str) {
  25. return str.replace(/(['\"]?version['\"]?\s*[:=]\s*['\"])[\\d.\\w\\-]+(['\"])/, function(_, m1, m2) {
  26. return m1 + version + m2;
  27. });
  28. }
  29. function update(path, replace) {
  30. var pkg = fs.readFileSync(path, 'utf8');
  31. pkg = (replace || replaceVersion)(pkg);
  32. fs.writeFileSync(path, pkg, 'utf8');
  33. }
  34. update('package.json');
  35. update('build/package.json');
  36. update('./lib/ace/ace.js');
  37. update('ChangeLog.txt', function(str) {
  38. var date='"`date +%Y.%m.%d`"';
  39. return date + ' Version ' + version + '\n' + str.replace(/^\d+.*/, '').replace(/^\n/, '');
  40. });
  41. "
  42. pause "versions updated. do you want to start build script? [y/n]"
  43. node Makefile.dryice.js full
  44. cd build
  45. git add .
  46. git commit --all -m "package `date +%d.%m.%y`"
  47. echo "build task completed."
  48. pause "continue creating the tag for v$VERSION_NUM [y/n]"
  49. if [[ ${VERSION_NUM} != *"-"* ]]; then
  50. git tag "v"$VERSION_NUM
  51. fi
  52. pause "continue pushing to github? [y/n]"
  53. git push --progress --tags "origin" HEAD:gh-pages HEAD:master
  54. echo "build repository updated"
  55. pause "continue update ace repo? [y/n]"
  56. cd ..
  57. echo "new commit added"
  58. pause "continue creating the tag for v$VERSION_NUM [y/n]"
  59. if [[ ${VERSION_NUM} != *"-"* ]]; then
  60. git tag "v"$VERSION_NUM
  61. fi
  62. pause "continue pushing to github? [y/n]"
  63. git push --progress --tags "origin" HEAD:gh-pages HEAD:master
  64. echo "All done!"
  65. pause "May I go now? [y/n]"