release.sh 685 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash -e
  2. changelog=node_modules/.bin/changelog
  3. update_version() {
  4. echo "$(node -p "p=require('./${1}');p.version='${2}';JSON.stringify(p,null,2)")" > $1
  5. echo "Updated ${1} version to ${2}"
  6. }
  7. current_version=$(node -p "require('./package').version")
  8. printf "Next version (current is $current_version)? "
  9. read next_version
  10. if ! [[ $next_version =~ ^[0-9]\.[0-9]+\.[0-9](-.+)? ]]; then
  11. echo "Version must be a valid semver string, e.g. 1.0.2 or 2.3.0-beta.1"
  12. exit 1
  13. fi
  14. next_ref="v$next_version"
  15. git add -u
  16. npm run build
  17. npm test
  18. update_version 'package.json' $next_version
  19. git commit -am "release $next_version"
  20. git tag $next_version
  21. git push --tags
  22. npm publish