From 8a0dc07d19a6e706613ed0bd72cd7c8a75b7a756 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Mon, 22 Jan 2024 16:11:38 +0100 Subject: [PATCH] Aligned build with other spec projects. --- .github/workflows/ci.yml | 37 +++++++++++ .github/workflows/prettier.yaml | 13 ++++ build.sh | 105 ++++++++++++++++++++++++++++++++ spec/metadata.json | 14 +++++ 4 files changed, 169 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/prettier.yaml create mode 100755 build.sh create mode 100644 spec/metadata.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d9e6430 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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" diff --git a/.github/workflows/prettier.yaml b/.github/workflows/prettier.yaml new file mode 100644 index 0000000..3f0ab09 --- /dev/null +++ b/.github/workflows/prettier.yaml @@ -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 diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..d1cc5a5 --- /dev/null +++ b/build.sh @@ -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=" + + GraphQL over HTTP Specification Versions + + + +

GraphQL over HTTP

+ " + +# Include latest draft +GITDATE=$(git show -s --format=%cd --date=format:"%a, %b %-d, %Y" HEAD) +HTML="$HTML + + + + + + " + +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 + " + + [ -z $HAS_LATEST_RELEASE ] && HTML="$HTML + " || HTML="$HTML + " + HAS_LATEST_RELEASE=1 + + HTML="$HTML + + + + " +done + +HTML="$HTML +
PrereleaseWorking Draft$GITDATE
Latest Release$TAGTITLE$GITDATERelease Notes
+ + +" + +echo $HTML > "public/index.html" diff --git a/spec/metadata.json b/spec/metadata.json new file mode 100644 index 0000000..b29048f --- /dev/null +++ b/spec/metadata.json @@ -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" + } + } +}