Skip to content

Commit

Permalink
Aligned build with other spec projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Jan 22, 2024
1 parent c7aad44 commit 8a0dc07
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "16.x"
- run: npm ci
- run: npm test
publish:
if: github.ref == 'refs/heads/main'
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: "16.x"
- run: npm ci
- run: npm run build
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
keep_files: true
user_name: "github-actions[bot]"
user_email: "github-actions[bot]@users.noreply.github.com"
13 changes: 13 additions & 0 deletions .github/workflows/prettier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Prettier formatting
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "16.x"
- run: npm ci
- run: npm run format:check
105 changes: 105 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,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/graphql-over-http/blame/main/" spec/GraphQLOverHTTP.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/graphql-over-http/blame/$GITTAG/" spec/GraphQLOverHTTP.md > "public/$GITTAG/index.html"
fi

# Create the index file
echo "Rebuilding: / (index)"
HTML="<html>
<head>
<title>GraphQL over HTTP 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 over HTTP</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-over-http/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"
14 changes: 14 additions & 0 deletions spec/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"biblio": {
"https://spec.graphql.org/draft/": {
"graphql-service": "#sec-Overview",
"graphql-schema": "#sec-Schema",
"graphql-request": "#request",
"graphql-response": "#sec-Response",
"graphql-request-error": "#sec-Errors.Request-errors",
"graphql-field-error": "#sec-Errors.Field-errors",
"graphql-document": "#sec-Document",
"graphql-validation": "#sec-Validation"
}
}
}

0 comments on commit 8a0dc07

Please sign in to comment.