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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 ]] || { 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. # Check out the named branch (or stay in current)
  24. git checkout $BRANCH
  25. if [[ $BRANCH == "gh-pages" ]]; then
  26. echo "Can't build from 'gh-pages.' Only the Jekyll branches (based on 'master')."
  27. exit
  28. fi
  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. # build the site statically and proof it
  77. bundle exec jekyll build --profile --trace --no-watch
  78. bundle exec htmlproofer ./_site --only-4xx --allow-hash-href --check-favicon --check-html --url-swap ".*marlinfw.org/:/"
  79. # Sync the built site into a temporary folder
  80. TMPFOLDER=$( mktemp -d )
  81. rsync -av _site/ ${TMPFOLDER}/
  82. # Clean out changes and other junk in the branch
  83. git reset --hard
  84. git clean -d -f
  85. # Copy built-site into the gh-pages branch
  86. git checkout gh-pages
  87. rsync -av ${TMPFOLDER}/ ./
  88. # Commit and push the new live site directly
  89. git add --all
  90. git commit --message "Built from ${COMMIT}"
  91. git push upstream
  92. # remove the temporary folder
  93. rm -rf ${TMPFOLDER}
  94. # Go back to the branch we started from
  95. git checkout $BRANCH
  96. [[ $HAS_STASH == 1 ]] && git stash pop