release.sh 952 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. set -e
  3. if [ "$TRAVIS_BRANCH" != "release" ]; then
  4. echo "Skipping release because this is not the 'release' branch"
  5. exit 0
  6. fi
  7. # Travis executes this script from the repository root, so at the same level than package.json
  8. VERSION=$(node -p -e "require('./package.json').version")
  9. # Make sure that the associated tag doesn't already exist
  10. GITTAG=$(git ls-remote origin refs/tags/v$VERSION)
  11. if [ "$GITTAG" != "" ]; then
  12. echo "Tag for package.json version already exists, aborting release"
  13. exit 1
  14. fi
  15. git remote add auth-origin https://$GITHUB_AUTH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git
  16. git config --global user.email "$GITHUB_AUTH_EMAIL"
  17. git config --global user.name "Chart.js"
  18. git checkout --detach --quiet
  19. git add -f dist/*.js bower.json
  20. git commit -m "Release $VERSION"
  21. git tag -a "v$VERSION" -m "Version $VERSION"
  22. git push -q auth-origin refs/tags/v$VERSION 2>/dev/null
  23. git remote rm auth-origin
  24. git checkout -f @{-1}