forked from graphql/composite-schemas-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·105 lines (94 loc) · 2.84 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash -e
# This script publishes the GraphQL specification document to the web.
# Determine if this is a tagged release
GITTAG=$(git tag --points-at HEAD)
# Build the specification draft document
echo "Building spec draft"
mkdir -p public/draft
spec-md --metadata spec/metadata.json --githubSource "https://github.com/graphql/composite-schemas-spec/blame/main/" spec/Spec.md > public/draft/index.html
# If this is a tagged commit, also build the release document
if [ -n "$GITTAG" ]; then
echo "Building spec release $GITTAG"
mkdir -p "public/$GITTAG"
spec-md --metadata spec/metadata.json --githubSource "https://github.com/graphql/composite-schemas-spec/blame/$GITTAG/" spec/Spec.md > "public/$GITTAG/index.html"
fi
# Create the index file
echo "Rebuilding: / (index)"
HTML="<html>
<head>
<title>GraphQL Composite Schemas Specification Versions</title>
<style>
body {
color: #333333;
font: 13pt/18pt Cambria, 'Palatino Linotype', Palatino, 'Liberation Serif', serif;
margin: 6rem auto 3rem;
max-width: 780px;
}
@media (min-width: 1240px) {
body {
padding-right: 300px;
}
}
a {
color: #3B5998;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
h1 {
font-size: 1.5em;
margin: 8rem 0 2em;
}
td {
padding-bottom: 5px;
}
td + td {
padding-left: 2ch;
}
</style>
</head>
<body>
<h1>GraphQL Composite Schemas</h1>
<table>"
# Include latest draft
GITDATE=$(git show -s --format=%cd --date=format:"%a, %b %-d, %Y" HEAD)
HTML="$HTML
<tr>
<td><em>Prerelease</em></td>
<td><a href=\"./draft\" keep-hash>Working Draft</a></td>
<td>$GITDATE</td>
<td></td>
</tr>"
GITHUB_RELEASES="https://github.com/graphql/graphql-composite-schemas-spec/releases/tag"
for GITTAG in $(git tag -l --sort='-*committerdate') ; do
VERSIONYEAR=${GITTAG: -4}
TAGTITLE="${GITTAG%$VERSIONYEAR} $VERSIONYEAR"
TAGGEDCOMMIT=$(git rev-list -1 "$GITTAG")
GITDATE=$(git show -s --format=%cd --date=format:"%a, %b %-d, %Y" $TAGGEDCOMMIT)
HTML="$HTML
<tr>"
[ -z $HAS_LATEST_RELEASE ] && HTML="$HTML
<td><em>Latest Release</em></td>" || HTML="$HTML
<td></td>"
HAS_LATEST_RELEASE=1
HTML="$HTML
<td><a href=\"./$GITTAG\" keep-hash>$TAGTITLE</a></td>
<td>$GITDATE</td>
<td><a href=\"$GITHUB_RELEASES/$GITTAG\">Release Notes</a></td>
</tr>"
done
HTML="$HTML
</table>
<script>
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
if (links[i].hasAttribute('keep-hash')) {
links[i].href += location.hash;
links[i].removeAttribute('keep-hash');
}
}
</script>
</body>
</html>"
echo $HTML > "public/index.html"