-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{ $currentVersion := getenv "CURRENT_VERSION" }} | ||
{{ $versionString := getenv "VERSIONS" }} | ||
{{ $versions := split $versionString "," }} | ||
{{ $latestVersion := index $versions 0 }} | ||
|
||
{{ if (eq $currentVersion "master") }} | ||
<div class="alert-warning"> | ||
You are looking at the docs for the unreleased <code>master</code> branch. The latest version is <a href="/$latestVersion">{{ $latestVersion }}</a>. | ||
</div> | ||
{{ else if not (eq $latestVersion $currentVersion) }} | ||
<div class="alert-warning"> | ||
You are looking at the docs for an older version ({{ $currentVersion }}). The latest version is <a href="/$latestVersion">{{ $latestVersion }}</a>. | ||
</div> | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{ $VersionString := getenv "VERSIONS" }} | ||
{{ $Versions := split $VersionString "," }} | ||
{{ $currentVersion := getenv "CURRENT_VERSION" }} | ||
|
||
<div class="version-switcher"> | ||
<span>{{ $currentVersion }}</span> | ||
<div class="version-switcher-options"> | ||
<a class="version-switcher-option">{{$currentVersion}}</a> | ||
{{ range $i, $version := $Versions }} | ||
{{ if not (eq $currentVersion $version) }} | ||
<a href="/{{$version}}/" class="version-switcher-option">{{$version}}</a> | ||
{{ end }} | ||
{{ end }} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters