You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.3 KiB

  1. #!/bin/bash
  2. if [[ `git status --porcelain` ]]; then
  3. # changes
  4. >&2 echo "You have unstaged changes. Please commit before you run this."
  5. exit 1
  6. fi
  7. # REPO=git@github.com:Blizzard/node-rdkafka.git
  8. REPO=https://github.com/Blizzard/node-rdkafka.git
  9. git remote add deploy $REPO
  10. # Get the most recent stuff if we don't have it
  11. git fetch deploy gh-pages || exit $?
  12. make docs || exit $?
  13. # Get package version and save to variable
  14. PACKAGE=$(node -pe 'require("./package.json").name.split("/")[1]')
  15. VERSION=$(node -pe 'require("./package.json").version')
  16. # Make a temporary folder
  17. TEMPDIR=$(mktemp -d)
  18. VERSIONDIR="$TEMPDIR/$VERSION"
  19. cp -r docs $VERSIONDIR
  20. # Now, checkout the gh-pages, but first get current checked out branch
  21. #
  22. CURRENT_BRANCH=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
  23. COMMIT_MESSAGE=$(git log --pretty='format:%B' -1)
  24. COMMIT_AUTHOR=$(git log --pretty='format:%aN <%aE>' -1)
  25. if [[ `git checkout --quiet -b gh-pages deploy/gh-pages` ]]; then
  26. >&2 echo "Could not checkout gh-pages"
  27. exit 1
  28. fi
  29. rm -rf current
  30. rm -rf $VERSION
  31. cp -r $VERSIONDIR $VERSION
  32. cp -r $VERSIONDIR current
  33. git add --all
  34. git commit --author="$COMMIT_AUTHOR" -m "Updated docs for '$COMMIT_MESSAGE'"
  35. rm -rf $TEMPDIR
  36. git push $REPO gh-pages || exit $?
  37. git checkout $CURRENT_BRANCH