My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. which xdg-open >/dev/null && TOOL=xdg-open
  62. which gnome-open >/dev/null && TOOL=gnome-open
  63. which open >/dev/null && TOOL=open
  64. URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1"
  65. if [ -z "$OPEN" ]; then
  66. echo "Can't find a tool to open the URL:"
  67. echo $URL
  68. else
  69. echo "Opening a New PR Form..."
  70. "$OPEN" "$URL"
  71. fi
  72. fi
  73. # Uncomment to compress the final html files
  74. # mv ./_plugins/jekyll-press.rb-disabled ./_plugins/jekyll-press.rb
  75. # bundle install
  76. echo
  77. echo "Generating MarlinDocumentation..."
  78. rm -rf _site
  79. # build the site statically and proof it
  80. bundle exec jekyll build --profile --trace --no-watch
  81. bundle exec htmlproofer ./_site --only-4xx --allow-hash-href --check-favicon --check-html --url-swap ".*marlinfw.org/:/"
  82. # Sync the built site into a temporary folder
  83. TMPFOLDER=$( mktemp -d )
  84. rsync -av _site/ ${TMPFOLDER}/
  85. # Clean out changes and other junk in the branch
  86. git reset --hard
  87. git clean -d -f
  88. # Copy built-site into the gh-pages branch
  89. git checkout gh-pages || { echo "Something went wrong!"; exit 1; }
  90. rsync -av ${TMPFOLDER}/ ./
  91. opensite() {
  92. which xdg-open >/dev/null && TOOL=xdg-open
  93. which gnome-open >/dev/null && TOOL=gnome-open
  94. which open >/dev/null && TOOL=open
  95. URL="http://marlinfw.org/"
  96. if [ -z "$OPEN" ]; then
  97. echo "Can't find a tool to open the URL:"
  98. echo $URL
  99. else
  100. echo "Opening the site in the browser..."
  101. "$OPEN" "$URL"
  102. fi
  103. }
  104. # Commit and push the new live site directly
  105. git add --all
  106. git commit --message "Built from ${COMMIT}"
  107. git push upstream | {
  108. while IFS= read -r line
  109. do
  110. [[ $line =~ "gh-pages -> gh-pages" ]] && opensite
  111. echo "$line"
  112. done
  113. }
  114. # remove the temporary folder
  115. rm -rf ${TMPFOLDER}
  116. # Go back to the branch we started from
  117. git checkout $BRANCH
  118. [[ $HAS_STASH == 1 ]] && git stash pop