Skip to content

Commit 8b9d351

Browse files
leebyronTravis CI
authored andcommitted
Add version index (#461)
Replaces out current index redirection script with a file which lists out all published and pre-released versions and no longer redirects automatically. Additionally, this retains the current hash so old links can be easily followed through to the intended spec version.
1 parent 57d1f10 commit 8b9d351

File tree

2 files changed

+78
-14
lines changed

2 files changed

+78
-14
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
git:
2-
depth: 5
2+
depth: false
33

44
language: node_js
55
node_js: 9

publish.sh

Lines changed: 77 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,97 @@ GITTAG=$(git tag --points-at HEAD)
1212
echo "Cloning gh-pages"
1313
rm -rf gh-pages
1414
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
1615

1716
# Replace /draft with this build.
1817
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
2120

2221
# If this is a tagged commit, publish to a permalink and index.
2322
if [ -n "$GITTAG" ]; then
2423
echo "Publishing to: /$GITTAG"
25-
cp -r ../out/ "$GITTAG"
24+
cp -r out/ "gh-pages/$GITTAG"
25+
fi
2626

27-
echo "Linking from: / (index)"
28-
echo '<html>
27+
# Create the index file
28+
echo "Rebuilding: / (index)"
29+
HTML="<html>
2930
<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>
3255
</head>
3356
<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>
3599
</body>
36-
</html>' > index.html
37-
fi
100+
</html>"
101+
102+
echo $HTML > "gh-pages/index.html"
38103

39104
echo "Pushing update"
105+
cd gh-pages
40106
git config user.name "Travis CI"
41107
git config user.email "[email protected]"
42108
git add -A .
@@ -47,5 +113,3 @@ else
47113
git push > /dev/null 2>&1
48114
echo "Pushed"
49115
fi
50-
51-
popd > /dev/null 2>&1

0 commit comments

Comments
 (0)