build-release.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/usr/bin/env bash
  2. # always immediately exit upon error
  3. set -e
  4. # start in project root
  5. cd "`dirname $0`/.."
  6. ./bin/require-clean-working-tree.sh
  7. read -p 'Have you already ran `npm update` and committed the package-lock.json? (y/N): ' updated_npm_deps
  8. if [[ "$updated_npm_deps" != "y" ]]
  9. then
  10. echo "Go do that!"
  11. exit 1
  12. fi
  13. read -p "Have you already updated the changelog? (y/N): " updated_changelog
  14. if [[ "$updated_changelog" != "y" ]]
  15. then
  16. echo "Go do that!"
  17. exit 1
  18. fi
  19. read -p "Would you like to update dates in the demos? (y/N): " update_demos
  20. if [[ "$update_demos" == "y" ]]
  21. then
  22. ./bin/update-demo-dates.sh
  23. fi
  24. read -p "Enter the new version number with no 'v' (for example '1.0.1'): " version
  25. if [[ ! "$version" ]]
  26. then
  27. echo "Aborting."
  28. exit 1
  29. fi
  30. success=0
  31. if {
  32. # ensures stray files stay out of the release
  33. npx gulp clean &&
  34. # update package manager json files with version number and release date
  35. npx gulp bump --version=$version &&
  36. # build all dist files, lint, and run tests
  37. npx gulp release
  38. }
  39. then
  40. # save reference to current branch
  41. current_branch=$(git symbolic-ref --quiet --short HEAD)
  42. # make a tagged detached commit of the dist files.
  43. # no-verify avoids commit hooks.
  44. if {
  45. git checkout --quiet --detach &&
  46. git add *.json &&
  47. git add -f dist/*.js dist/*.d.ts dist/*.css dist/locale/*.js &&
  48. git commit --quiet --no-verify -e -m "version $version" &&
  49. git tag -a "v$version" -m "version $version"
  50. }
  51. then
  52. success=1
  53. fi
  54. # return to branch
  55. git checkout --quiet "$current_branch"
  56. fi
  57. if [[ "$success" == "1" ]]
  58. then
  59. # keep newly generated dist files around
  60. git checkout --quiet "v$version" -- dist
  61. git reset --quiet -- dist
  62. echo "Success."
  63. else
  64. # unstage all dist/ or *.json changes
  65. git reset --quiet
  66. # discard changes from version bump
  67. git checkout --quiet -- *.json
  68. echo "Failure."
  69. exit 1
  70. fi