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.

77 lines
2.2 KiB

  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. if [ "$CIRCLE_BRANCH" == "" ]; then
  4. echo "this script is meant to be run on CircleCI, exiting"
  5. echo 1
  6. fi
  7. # check for changes in the `rpc/core` directory
  8. did_rpc_change=$(git diff --name-status $CIRCLE_BRANCH origin/master | grep rpc/core)
  9. if [ "$did_rpc_change" == "" ]; then
  10. echo "no changes detected in rpc/core, exiting"
  11. exit 0
  12. else
  13. echo "changes detected in rpc/core, continuing"
  14. fi
  15. # only run this script on changes to rpc/core committed to develop
  16. if [ "$CIRCLE_BRANCH" != "master" ]; then
  17. echo "the branch being built isn't master, exiting"
  18. exit 0
  19. else
  20. echo "on master, building the RPC docs"
  21. fi
  22. # godoc2md used to convert the go documentation from
  23. # `rpc/core` into a markdown file consumed by Slate
  24. go get github.com/davecheney/godoc2md
  25. # slate works via forks, and we'll be committing to
  26. # master branch, which will trigger our fork to run
  27. # the `./deploy.sh` and publish via the `gh-pages` branch
  28. slate_repo=github.com/tendermint/slate
  29. slate_path="$GOPATH"/src/"$slate_repo"
  30. if [ ! -d "$slate_path" ]; then
  31. git clone https://"$slate_repo".git $slate_path
  32. fi
  33. # the main file we need to update if rpc/core changed
  34. destination="$slate_path"/source/index.html.md
  35. # we remove it then re-create it with the latest changes
  36. rm $destination
  37. header="---
  38. title: RPC Reference
  39. language_tabs:
  40. - shell
  41. - go
  42. toc_footers:
  43. - <a href='https://tendermint.com/'>Tendermint</a>
  44. - <a href='https://github.com/lord/slate'>Documentation Powered by Slate</a>
  45. search: true
  46. ---"
  47. # write header to the main slate file
  48. echo "$header" > "$destination"
  49. # generate a markdown from the godoc comments, using a template
  50. rpc_docs=$(godoc2md -template rpc/core/doc_template.txt github.com/tendermint/tendermint/rpc/core | grep -v -e "pipe.go" -e "routes.go" -e "dev.go" | sed 's$/src/target$https://github.com/tendermint/tendermint/tree/master/rpc/core$')
  51. # append core RPC docs
  52. echo "$rpc_docs" >> "$destination"
  53. # commit the changes
  54. cd $slate_path
  55. git config --global user.email "github@tendermint.com"
  56. git config --global user.name "tenderbot"
  57. git commit -a -m "Update tendermint RPC docs via CircleCI"
  58. git push -q https://${GITHUB_ACCESS_TOKEN}@github.com/tendermint/slate.git master