release.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. if [ -z "`which github-changes`" ]; then
  3. # specify version because github-changes "is under heavy development. Things
  4. # may break between releases" until 0.1.0
  5. echo "First, do: [sudo] npm install -g github-changes@0.0.14"
  6. exit 1
  7. fi
  8. if [ -d .git/refs/remotes/upstream ]; then
  9. remote=upstream
  10. else
  11. remote=origin
  12. fi
  13. # Increment v2.x.y -> v2.x+1.0
  14. npm version minor || exit 1
  15. # Generate changelog from pull requests
  16. github-changes -o request -r request \
  17. --auth --verbose \
  18. --file CHANGELOG.md \
  19. --only-pulls --use-commit-body \
  20. --date-format '(YYYY/MM/DD)' \
  21. || exit 1
  22. # Since the tag for the new version hasn't been pushed yet, any changes in it
  23. # will be marked as "upcoming"
  24. version="$(grep '"version"' package.json | cut -d'"' -f4)"
  25. sed -i -e "s/^### upcoming/### v$version/" CHANGELOG.md
  26. # This may fail if no changelog updates
  27. # TODO: would this ever actually happen? handle it better?
  28. git add CHANGELOG.md; git commit -m 'Update changelog'
  29. # Publish the new version to npm
  30. npm publish || exit 1
  31. # Increment v2.x.0 -> v2.x.1
  32. # For rationale, see:
  33. # https://github.com/request/oauth-sign/issues/10#issuecomment-58917018
  34. npm version patch || exit 1
  35. # Push back to the main repo
  36. git push $remote master --tags || exit 1