github.com/maeglindeveloper/gqlgen@v0.13.1-0.20210413081235-57808b12a0a0/docs/build.sh (about) 1 #!/bin/bash 2 # 3 # This was adapted from https://github.com/dgraph-io/dgraph/blob/master/wiki/scripts/build.sh 4 # 5 6 set -e 7 8 GREEN='\033[32;1m' 9 RESET='\033[0m' 10 HOST=https://gqlgen.com 11 12 VERSIONS_ARRAY=( 13 'v0.13.0' 14 'origin/master' 15 'v0.12.2' 16 'v0.11.3' 17 'v0.10.2' 18 'v0.9.3' 19 'v0.8.3' 20 ) 21 22 joinVersions() { 23 versions=$(printf ",%s" "${VERSIONS_ARRAY[@]}" | sed 's/origin\/master/master/') 24 echo "${versions:1}" 25 } 26 27 function version { echo "$@" | gawk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; } 28 29 rebuild() { 30 VERSION_STRING=$(joinVersions) 31 export CURRENT_VERSION=${1} 32 if [[ $CURRENT_VERSION == 'origin/master' ]] ; then 33 CURRENT_VERSION="master" 34 fi 35 36 export VERSIONS=${VERSION_STRING} 37 38 hugo --quiet --destination="public/$CURRENT_VERSION" --baseURL="$HOST/$CURRENT_VERSION/" 39 40 if [[ $1 == "${VERSIONS_ARRAY[0]}" ]]; then 41 hugo --quiet --destination=public/ --baseURL="$HOST/" 42 fi 43 } 44 45 46 currentBranch=$(git rev-parse --abbrev-ref HEAD) 47 48 if ! git remote | grep -q origin ; then 49 git remote add origin https://github.com/99designs/gqlgen 50 fi 51 git fetch origin --tags 52 53 for version in "${VERSIONS_ARRAY[@]}" ; do 54 echo -e "$(date) $GREEN Updating docs for $version.$RESET" 55 rm -rf content 56 git checkout $version -- content 57 rebuild "$version" 58 done 59 60 rm -rf content 61 git checkout "$currentBranch" -- content 62