From d00448b07ad0cc673df57a0077761ff9a518d84a Mon Sep 17 00:00:00 2001 From: rschoene <rene.schoene@tu-dresden.de> Date: Wed, 24 Nov 2021 10:20:08 +0100 Subject: [PATCH] Use mike for versioned documentation --- .gitlab-ci.yml | 25 +++++++++++++++++++------ pages/main.py | 4 ++++ pages/requirements.txt | 4 ++++ 3 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 pages/requirements.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 70f955c..f9a4bfb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -90,18 +90,31 @@ ragdoc_view: - "pages/docs/ragdoc" pages: - image: python:3.8-buster + image: python:3.10.0-bullseye stage: publish needs: - ragdoc_view - test + variables: + PAGES_BRANCH: pages + HTTPS_REMOTE: https://${PROJECT_BOT_USER}:${PROJECT_BOT_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git before_script: - - pip install -U mkdocs mkdocs-macros-plugin mkdocs-git-revision-date-localized-plugin + - pip install -r pages/requirements.txt + - git config user.name $PROJECT_BOT_USER + - git config user.email $PROJECT_BOT_USER@git-st.inf.tu-dresden.de + - git fetch origin $PAGES_BRANCH || echo "Pages branch not deployed yet." + - git checkout $CI_COMMIT_SHA script: - - cd pages && mkdocs build + - cd pages + - export VERSION=$(python main.py) + - echo $VERSION + - mike list --json --prefix public -r $HTTPS_REMOTE -b $PAGES_BRANCH + - mike deploy --rebase --prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH --update-aliases $VERSION + - cd .. + - git checkout $PAGES_BRANCH -- public/ + artifacts: + paths: + - public/ only: - dev - master - artifacts: - paths: - - public diff --git a/pages/main.py b/pages/main.py index 5f574f6..34fc17a 100644 --- a/pages/main.py +++ b/pages/main.py @@ -1,7 +1,11 @@ +import os + ragconnectVersionFileName = '../ragconnect.base/src/main/resources/ragConnectVersion.properties' def get_version(): + if os.environ.get('CI_COMMIT_BRANCH', 'unknown') == 'dev': + return 'dev' with open(ragconnectVersionFileName) as ragconnectVersionFile: versionFileContent = ragconnectVersionFile.read() return versionFileContent[versionFileContent.rindex('version=') + 8:].strip() diff --git a/pages/requirements.txt b/pages/requirements.txt new file mode 100644 index 0000000..43e5e82 --- /dev/null +++ b/pages/requirements.txt @@ -0,0 +1,4 @@ +mkdocs==1.2.2 +mkdocs-git-revision-date-localized-plugin==0.10.3 +mkdocs-macros-plugin==0.6.3 +mike==1.1.2 -- GitLab