diff --git a/docs/build.sh b/docs/build.sh new file mode 100755 index 00000000000..15234cdc213 --- /dev/null +++ b/docs/build.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# This was adapted from https://github.com/dgraph-io/dgraph/blob/master/wiki/scripts/build.sh +# + +set -e + +GREEN='\033[32;1m' +RESET='\033[0m' +HOST=https://gqlgen.com + +VERSIONS_ARRAY=( + 'v0.10.2' + 'master' + 'v0.9.3' + 'v0.8.3' + 'v0.7.2' + 'v0.6.0' + 'v0.5.1' + 'v0.4.4' +) + +joinVersions() { + versions=$(printf ",%s" "${VERSIONS_ARRAY[@]}") + echo "${versions:1}" +} + +function version { echo "$@" | gawk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; } + +rebuild() { + echo -e "$(date) $GREEN Updating docs for branch: $1.$RESET" + + + VERSION_STRING=$(joinVersions) + export CURRENT_VERSION=${1} + export VERSIONS=${VERSION_STRING} + + hugo --quiet --destination="public/$CURRENT_VERSION" --baseURL="$HOST/$CURRENT_VERSION" + + if [[ $1 == "${VERSIONS_ARRAY[0]}" ]]; then + hugo --quiet --destination=public/ --baseURL="$HOST/" + fi +} + + +currentBranch=$(git rev-parse --abbrev-ref HEAD) + +git fetch origin + +for version in "${VERSIONS_ARRAY[@]}" ; do + git checkout $branch + rebuild "$version" +done + +git checkout -q "$currentBranch" + diff --git a/docs/layouts/_default/baseof.html b/docs/layouts/_default/baseof.html index 70eea20aba6..9a504891013 100644 --- a/docs/layouts/_default/baseof.html +++ b/docs/layouts/_default/baseof.html @@ -27,6 +27,7 @@
+ {{ partial "version-switcher" . }} {{ partial "sidebar" . }} {{ block "main" . }}{{ end }} -