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