@@ -12,31 +12,97 @@ GITTAG=$(git tag --points-at HEAD)
12
12
echo " Cloning gh-pages"
13
13
rm -rf gh-pages
14
14
git clone -b gh-pages " https://${GH_TOKEN} @github.com/facebook/graphql.git" gh-pages > /dev/null 2>&1
15
- pushd gh-pages > /dev/null 2>&1
16
15
17
16
# Replace /draft with this build.
18
17
echo " Publishing to: /draft"
19
- rm -rf draft
20
- cp -r ../ out/ draft
18
+ rm -rf gh-pages/ draft
19
+ cp -r out/ gh-pages/ draft
21
20
22
21
# If this is a tagged commit, publish to a permalink and index.
23
22
if [ -n " $GITTAG " ]; then
24
23
echo " Publishing to: /$GITTAG "
25
- cp -r ../out/ " $GITTAG "
24
+ cp -r out/ " gh-pages/$GITTAG "
25
+ fi
26
26
27
- echo " Linking from: / (index)"
28
- echo ' <html>
27
+ # Create the index file
28
+ echo " Rebuilding: / (index)"
29
+ HTML=" <html>
29
30
<head>
30
- <meta http-equiv="refresh" content="0; url=./' " $GITTAG " ' " />
31
- <title>GraphQL Specification</title>
31
+ <title>GraphQL Specification Versions</title>
32
+ <style>
33
+ body {
34
+ color: #333333;
35
+ font: 13pt/18pt Cambria, 'Palatino Linotype', Palatino, 'Liberation Serif', serif;
36
+ margin: 6rem auto 3rem;
37
+ max-width: 780px;
38
+ }
39
+ @media (min-width: 1240px) {
40
+ body {
41
+ padding-right: 300px;
42
+ }
43
+ }
44
+ h1 {
45
+ font-size: 1.5em;
46
+ margin: 8rem 0 2em;
47
+ }
48
+ td {
49
+ padding-bottom: 5px;
50
+ }
51
+ td + td {
52
+ padding-left: 2ch;
53
+ }
54
+ </style>
32
55
</head>
33
56
<body>
34
- Redirecting to the latest release: <a href="./' " $GITTAG " ' ">' " $GITTAG " ' </a>
57
+ <h1>GraphQL</h1>
58
+ <table>"
59
+
60
+ # Include latest draft
61
+ GITDATE=$( git show -s --format=%cd --date=format:" %a, %b %-d, %Y" HEAD)
62
+ HTML=" $HTML
63
+ <tr>
64
+ <td><em>Prerelease</em></td>
65
+ <td><a href=\" ./draft\" keep-hash>Working Draft</a></td>
66
+ <td>$GITDATE </td>
67
+ <td></td>
68
+ </tr>"
69
+
70
+ GITHUB_RELEASES=" https://github.com/facebook/graphql/releases/tag"
71
+ for GITTAG in $( git tag -l --sort=' -*committerdate' ) ; do
72
+ HTML=" $HTML
73
+ <tr>"
74
+
75
+ [ -z $HAS_LATEST_RELEASE ] && HTML=" $HTML
76
+ <td><em>Latest Release</em></td>" || HTML=" $HTML
77
+ <td></td>"
78
+ HAS_LATEST_RELEASE=1
79
+
80
+ TAGGEDCOMMIT=$( git rev-list -1 " $GITTAG " )
81
+ GITDATE=$( git show -s --format=%cd --date=format:" %a, %b %-d, %Y" $TAGGEDCOMMIT )
82
+ HTML=" $HTML
83
+ <td><a href=\" ./$GITTAG \" keep-hash>$GITTAG </a></td>
84
+ <td>$GITDATE </td>
85
+ <td><a href=\" $GITHUB_RELEASES /$GITTAG \" >Release Notes</a></td>
86
+ </tr>"
87
+ done
88
+
89
+ HTML=" $HTML
90
+ </table>
91
+ <script>
92
+ var links = document.getElementsByTagName('a');
93
+ for (var i = 0; i < links.length; i++) {
94
+ if (links[i].hasAttribute('keep-hash')) {
95
+ links[i].href += location.hash;
96
+ }
97
+ }
98
+ </script>
35
99
</body>
36
- </html>' > index.html
37
- fi
100
+ </html>"
101
+
102
+ echo $HTML > " gh-pages/index.html"
38
103
39
104
echo " Pushing update"
105
+ cd gh-pages
40
106
git config user.name " Travis CI"
41
107
git config user.email
" [email protected] "
42
108
git add -A .
47
113
git push > /dev/null 2>&1
48
114
echo " Pushed"
49
115
fi
50
-
51
- popd > /dev/null 2>&1
0 commit comments