update_pepsi_docs.sh (2009B)
1 #!/bin/sh 2 3 set -eu 4 5 fetch () { 6 git clean -fdx 7 git fetch 8 # reset to updated upstream branch, but only if we're tracking a branch 9 branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null || echo HEAD) 10 git reset --hard "$branch" 11 } 12 13 # Assumes the repo was already checked out once. 14 cd $HOME/pepsi 15 16 git checkout master -f 17 fetch 18 # No 'git submodule update': the only submodule (vendor/taler-rust) is a Rust 19 # dependency, the manual builds from docs/manual alone. 20 21 # 'make docs-html' builds the manual for *every* language of DOC_LANGUAGES into 22 # docs/manual/_build/html/<lang>/<version>/, plus an index.html at the root of 23 # that tree redirecting to the default language and version. Note that the 24 # preceding 'git clean -fdx' wipes the build tree, so each run publishes only 25 # the version that is current in master. 26 make docs-html 27 mv docs/manual/_build/html/ $HOME/pepsi.taler.net.wip 28 29 # Per-language entry points: /<lang>/ -> /<lang>/<newest version>/. 'make 30 # docs-html' only writes a redirect at the root of the tree, but the nginx 31 # Accept-Language map redirects to /<lang>/, which would otherwise 404. The 32 # version is read back from the built tree, so neither this script nor the 33 # nginx configuration has to be touched when DOC_VERSION changes. 34 for langdir in $HOME/pepsi.taler.net.wip/*/; do 35 version=$(ls "$langdir" | sort -V | tail -n1) 36 printf '<!DOCTYPE html>\n<html><head><meta charset="utf-8">\n<meta http-equiv="refresh" content="0; url=%s/index.html">\n<link rel="canonical" href="%s/index.html">\n</head><body>\nRedirecting to the <a href="%s/index.html">Pepsi manual</a>.\n</body></html>\n' \ 37 "$version" "$version" "$version" > "${langdir}index.html" 38 done 39 40 chmod -R g+rx $HOME/pepsi.taler.net.wip/ 41 42 # Clean up 'ancient' version (before previous) 43 rm -rf $HOME/pepsi.taler.net.old/ 44 # Finally, do two fast renames to make the current version active 45 mv $HOME/pepsi.taler.net/ $HOME/pepsi.taler.net.old/ || true 46 mv $HOME/pepsi.taler.net.wip/ $HOME/pepsi.taler.net/