#!/bin/bash set -e git config --global pull.ff only DOCS_DIR="/tmp/kanidm_docs" echo "DOCS DIR: ${DOCS_DIR}" echo "PWD: $(pwd)" if [ "${GITHUB_ACTIONS}" ]; then echo "Running in Github Actions" git config user.email "kanidm@kanidm.com" git config user.name "Kanidm Github Actions Runner" fi git fetch --all function build_version() { BOOK_VERSION=$1 echo "Book version: ${BOOK_VERSION}" echo "
  • ${BOOK_VERSION}
  • " >> "${DOCS_DIR}/index.html" if [ "$(git branch --show-current)" != "${BOOK_VERSION}" ]; then git switch -c "${BOOK_VERSION}" || git switch "${BOOK_VERSION}" fi echo "Running mdbook build" mdbook build book echo "Running cargo doc" cargo doc --quiet --no-deps echo "Moving book to ${DOCS_DIR}/${BOOK_VERSION}/" mv ./book/book/ "${DOCS_DIR}/${BOOK_VERSION}/" echo "Cleaning out rustdoc dir..." rm -rf "${DOCS_DIR}/${BOOK_VERSION}/rustdoc/" echo "Moving rustdoc to ${DOCS_DIR}/${BOOK_VERSION}/rustdoc/" mkdir -p "${DOCS_DIR}/${BOOK_VERSION}/rustdoc/" mv ./target/doc/* "${DOCS_DIR}/${BOOK_VERSION}/rustdoc/" } echo "Cleaning old docs dir" rm -rf "${DOCS_DIR}" mkdir -p "${DOCS_DIR}" cat > "${DOCS_DIR}/index.html" <<-'EOM' kanidm docs root

    Kanidm docs

    EOM ls -la "${DOCS_DIR}" rm -rf ./docs/ mv "${DOCS_DIR}" ./docs/ ln -s "${LATEST}" ./docs/stable