My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

mfpub 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #!/usr/bin/env bash
  2. #
  3. # mfpub
  4. #
  5. # Use Jekyll to generate Marlin Documentation, which is then
  6. # git-pushed to Github to publish it to the live site.
  7. # This publishes the current branch, and doesn't force
  8. # changes to be pushed to the 'master' branch. Be sure to push
  9. # any permanent changes to 'master'.
  10. #
  11. [[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [branch]" 1>&2 ; exit 1; }
  12. MFINFO=$(mfinfo "$@") || exit 1
  13. IFS=' ' read -a INFO <<< "$MFINFO"
  14. ORG=${INFO[0]}
  15. FORK=${INFO[1]}
  16. REPO=${INFO[2]}
  17. TARG=${INFO[3]}
  18. BRANCH=${INFO[4]}
  19. if [[ $ORG != "MarlinFirmware" || $REPO != "MarlinDocumentation" ]]; then
  20. echo "Wrong repository."
  21. exit
  22. fi
  23. if [[ $BRANCH == "gh-pages" ]]; then
  24. echo "Can't build from 'gh-pages.' Only the Jekyll branches (based on 'master')."
  25. exit
  26. fi
  27. # Check out the named branch (or stay in current)
  28. git checkout $BRANCH
  29. echo "Stashing any changes to files..."
  30. echo "Don't forget to update and push 'master'!"
  31. # GOJF Card
  32. [[ $(git stash) != "No local "* ]] && HAS_STASH=1
  33. COMMIT=$( git log --format="%H" -n 1 )
  34. # Clean out changes and other junk in the branch
  35. git clean -d -f
  36. # Push 'master' to the fork and make a proper PR...
  37. if [[ $BRANCH == "master" ]]; then
  38. # Don't lose upstream changes!
  39. git fetch upstream
  40. # Rebase onto latest master
  41. if git rebase upstream/master; then
  42. # Allow working directly with the main fork
  43. echo
  44. echo -n "Pushing to origin/master... "
  45. git push -f origin
  46. echo
  47. echo -n "Pushing to upstream/master... "
  48. git push -f upstream
  49. else
  50. echo "Merge conflicts? Stopping here."
  51. exit
  52. fi
  53. else
  54. if [ -z "$(git branch -vv | grep ^\* | grep \\\[origin)" ]; then
  55. firstpush
  56. else
  57. echo
  58. echo -n "Pushing to origin/$BRANCH... "
  59. git push -f origin
  60. fi
  61. TOOL=$(which gnome-open xdg-open open | awk '{ print $1 }')
  62. URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
  63. if [ -z "$TOOL" ]; then
  64. echo "Can't find a tool to open the URL:"
  65. echo $URL
  66. else
  67. echo "Opening a New PR Form..."
  68. "$TOOL" "$URL"
  69. fi
  70. fi
  71. # Uncomment to compress the final html files
  72. # mv ./_plugins/jekyll-press.rb-disabled ./_plugins/jekyll-press.rb
  73. # bundle install
  74. echo
  75. echo "Generating MarlinDocumentation..."
  76. rm -rf _site
  77. # build the site statically and proof it
  78. bundle exec jekyll build --profile --trace --no-watch
  79. bundle exec htmlproofer ./_site --only-4xx --allow-hash-href --check-favicon --check-html --url-swap ".*marlinfw.org/:/"
  80. # Sync the built site into a temporary folder
  81. TMPFOLDER=$( mktemp -d )
  82. rsync -av _site/ ${TMPFOLDER}/
  83. # Clean out changes and other junk in the branch
  84. git reset --hard
  85. git clean -d -f
  86. # Copy built-site into the gh-pages branch
  87. git checkout gh-pages || { echo "Something went wrong!"; exit 1; }
  88. rsync -av ${TMPFOLDER}/ ./
  89. opensite() {
  90. TOOL=$(which gnome-open xdg-open open | awk '{ print $1 }')
  91. URL="http://marlinfw.org/"
  92. if [ -z "$TOOL" ]; then
  93. echo "Can't find a tool to open the URL:"
  94. echo $URL
  95. else
  96. echo "Opening the site in the browser..."
  97. "$TOOL" "$URL"
  98. fi
  99. }
  100. # Commit and push the new live site directly
  101. git add --all
  102. git commit --message "Built from ${COMMIT}"
  103. git push upstream | {
  104. while IFS= read -r line
  105. do
  106. [[ $line =~ "gh-pages -> gh-pages" ]] && opensite
  107. echo "$line"
  108. done
  109. }
  110. # remove the temporary folder
  111. rm -rf ${TMPFOLDER}
  112. # Go back to the branch we started from
  113. git checkout $BRANCH
  114. [[ $HAS_STASH == 1 ]] && git stash pop