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 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. MFINFO=$(mfinfo "$@") || exit
  12. IFS=' ' read -a INFO <<< "$MFINFO"
  13. ORG=${INFO[0]}
  14. FORK=${INFO[1]}
  15. REPO=${INFO[2]}
  16. TARG=${INFO[3]}
  17. BRANCH=${INFO[4]}
  18. if [[ $ORG != "MarlinFirmware" || $REPO != "MarlinDocumentation" ]]; then
  19. echo "Wrong repository."
  20. exit
  21. fi
  22. # Check out the named branch (or stay in current)
  23. git checkout $BRANCH
  24. if [[ $BRANCH == "gh-pages" ]]; then
  25. echo "Can't build from 'gh-pages.' Only the Jekyll branches (based on 'master')."
  26. exit
  27. fi
  28. echo "Stashing any changes to files..."
  29. echo "Don't forget to update and push 'master'!"
  30. # GOJF Card
  31. git stash
  32. COMMIT=$( git log --format="%H" -n 1 )
  33. # Clean out changes and other junk in the branch
  34. git clean -d -f
  35. # Push 'master' to the fork and make a proper PR...
  36. if [[ $BRANCH == "master" ]]; then
  37. # Allow working directly with the main fork
  38. echo
  39. echo -n "Pushing to origin/master... "
  40. git push -f origin
  41. echo
  42. echo -n "Pushing to upstream/master... "
  43. git push -f upstream
  44. else
  45. if [ -z "$(git branch -vv | grep ^\* | grep \\[origin)" ]; then
  46. firstpush
  47. else
  48. echo
  49. echo -n "Pushing to origin/$BRANCH... "
  50. git push -f origin
  51. fi
  52. TOOL=$(which gnome-open xdg-open open | awk '{ print $1 }')
  53. URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
  54. if [ -z "$TOOL" ]; then
  55. echo "Can't find a tool to open the URL:"
  56. echo $URL
  57. else
  58. echo "Opening a New PR Form..."
  59. "$TOOL" "$URL"
  60. fi
  61. fi
  62. # Uncomment to compress the final html files
  63. # mv ./_plugins/jekyll-press.rb-disabled ./_plugins/jekyll-press.rb
  64. # bundle install
  65. echo
  66. echo "Generating MarlinDocumentation..."
  67. # build the site statically and proof it
  68. bundle exec jekyll build --profile --trace --no-watch
  69. bundle exec htmlproofer ./_site --only-4xx --allow-hash-href --check-favicon --check-html --url-swap ".*marlinfw.org/:/"
  70. # Sync the built site into a temporary folder
  71. TMPFOLDER=$( mktemp -d )
  72. rsync -av _site/ ${TMPFOLDER}/
  73. # Clean out changes and other junk in the branch
  74. git reset --hard
  75. git clean -d -f
  76. # Copy built-site into the gh-pages branch
  77. git checkout gh-pages
  78. rsync -av ${TMPFOLDER}/ ./
  79. # Commit and push the new live site directly
  80. git add --all
  81. git commit --message "Built from ${COMMIT}"
  82. git push upstream
  83. # remove the temporary folder
  84. rm -rf ${TMPFOLDER}
  85. # Go back to the branch we started from
  86. git checkout $BRANCH
  87. if [[ $BRANCH != "master" ]]; then
  88. git stash pop
  89. fi