publish-release.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 "Enter the version you want to publish, with no 'v' (for example '1.0.1'): " version
  8. if [[ ! "$version" ]]
  9. then
  10. echo "Aborting."
  11. exit 1
  12. fi
  13. # push the current branch (assumes tracking is set up) and the tag
  14. git push --recurse-submodules=on-demand
  15. git push origin "v$version"
  16. success=0
  17. # save reference to current branch
  18. current_branch=$(git symbolic-ref --quiet --short HEAD)
  19. # temporarily checkout the tag's commit, publish to NPM
  20. git checkout --quiet "v$version"
  21. if npm publish --tag legacy
  22. then
  23. success=1
  24. fi
  25. # return to branch
  26. git checkout --quiet "$current_branch"
  27. # restore generated dist files
  28. git checkout --quiet "v$version" -- dist
  29. git reset --quiet -- dist
  30. if [[ "$success" == "1" ]]
  31. then
  32. echo "Waiting for release to propagate to NPM..."
  33. sleep 10
  34. ./bin/verify-npm.sh
  35. echo
  36. echo 'Success.'
  37. echo 'You can now run:'
  38. echo ' ./bin/update-example-repo-deps.sh &&'
  39. echo ' git push --recurse-submodules=on-demand &&'
  40. echo ' ./bin/build-example-repos.sh --recent-release'
  41. echo
  42. else
  43. echo
  44. echo 'Failure.'
  45. echo
  46. exit 1
  47. fi