From b39d6c5fa63cacdeaa53021a2b8952484b97f207 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Thu, 18 Feb 2021 09:28:25 +0100
Subject: [PATCH] [doxygen] Implemented release branch docs.

Will be available at e.g. https://doxygen.opengeosys.org/v6.3.3
---
 Documentation/mainpage.dox.in                     |  5 +++--
 README.md                                         |  6 +++---
 scripts/ci/jobs/build-docs.yml                    | 15 +++++++++++++--
 scripts/doc/_redirects                            |  1 +
 .../docs/devguide/procedures/publish-a-release.md |  9 +++++++++
 5 files changed, 29 insertions(+), 7 deletions(-)
 create mode 100644 scripts/doc/_redirects

diff --git a/Documentation/mainpage.dox.in b/Documentation/mainpage.dox.in
index 6e1fb0c3a05..ec276c8eef7 100644
--- a/Documentation/mainpage.dox.in
+++ b/Documentation/mainpage.dox.in
@@ -19,8 +19,9 @@
  * You will find the Doxygen documentation for the development branch at
  * https://doxygen.opengeosys.org.
  *
- * The documenation for the latest OGS release is
- * https://doxygen.opengeosys.org/release.
+ * The documentation for OGS releases can be found here:
+ *
+ * - https://doxygen.opengeosys.org/v6.3.3
  *
  * \section useful_links Useful links
  * - OGS home page: https://opengeosys.org/
diff --git a/README.md b/README.md
index 89d587fcb7a..f3d37849015 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ waste deposition. OGS is comprised of the THMC-simulator (simply referred to as
 
 - Good starting point for users as well as for developers is the [documentation][documentation]
 - Check your code against our [styleguide](http://ufz.github.io/styleguide/cppguide.xml)
-- Have a look at the [source code documentation for the nightly build][docs-nightly] or [for the latest release][docs-release]
+- Have a look at the [source code documentation for the current master-branch build][docs-master] or [for the latest release][docs-release]
 
 ## License ##
 
@@ -28,6 +28,6 @@ OpenGeoSys is distributed under the Modified BSD License. See the
 
 [ogs]: https://www.opengeosys.org
 [documentation]: https://www.opengeosys.org/docs/
-[docs-nightly]: https://doxygen.opengeosys.org/
-[docs-release]: https://doxygen.opengeosys.org/release
+[docs-master]: https://doxygen.opengeosys.org/
+[docs-release]: https://doxygen.opengeosys.org/v6.3.3
 [license-source]: https://github.com/ufz/ogs/blob/master/LICENSE.txt
diff --git a/scripts/ci/jobs/build-docs.yml b/scripts/ci/jobs/build-docs.yml
index b4e0e523bbe..bcd8f6367a4 100644
--- a/scripts/ci/jobs/build-docs.yml
+++ b/scripts/ci/jobs/build-docs.yml
@@ -15,6 +15,7 @@ build docs:
   script:
     - cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DOGS_USE_CONAN=OFF -DOGS_BUILD_PROCESSES=GroundwaterFlow
     - cmake --build . --target doc > >(tee make-docs.output)
+    - cp ../scripts/doc/_redirects docs
   artifacts:
     expose_as: 'Doxygen'
     paths:
@@ -44,9 +45,19 @@ deploy doxygen:
   tags: [ docker ]
   image: $WEB_IMAGE
   rules:
-    - if: '$CI_COMMIT_BRANCH == "master"'
+    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+      variables:
+        ON_MASTER: "true"
+    - if: $CI_COMMIT_BRANCH =~ /^v[0-9]\.[0-9]\.[0-9]/
   dependencies: [meta_container, "build docs"]
   variables:
     GIT_STRATEGY: none
   script:
-    - netlify deploy --prod --dir=build/docs --site=$DOXYGEN_NETLIFY_SITE_ID
+  # ${CI_COMMIT_BRANCH//./-} replaces dots with hyphens
+    - |
+      if [ "$ON_MASTER" == "true" ]; then
+          netlify deploy --prod --dir=build/docs --site=$DOXYGEN_NETLIFY_SITE_ID
+      else
+          netlify link --name ogs-doxygen-${CI_COMMIT_BRANCH//./-}
+          netlify deploy --prod --dir=build/docs
+      fi
diff --git a/scripts/doc/_redirects b/scripts/doc/_redirects
new file mode 100644
index 00000000000..5ada709304c
--- /dev/null
+++ b/scripts/doc/_redirects
@@ -0,0 +1 @@
+/v6.3.3/* https://ogs-doxygen-v6-3-3.netlify.app/:splat 200!
diff --git a/web/content/docs/devguide/procedures/publish-a-release.md b/web/content/docs/devguide/procedures/publish-a-release.md
index a64fa7d4da5..f464290e1bc 100644
--- a/web/content/docs/devguide/procedures/publish-a-release.md
+++ b/web/content/docs/devguide/procedures/publish-a-release.md
@@ -14,6 +14,9 @@ weight = 1051
 - Update [merge request template](https://gitlab.opengeosys.org/ogs/ogs/edit) to point to a new changelog wiki page
 - Update `CHANGELOG.md` to point to new GitLab release
 - Create new web release page with generated artifact names and changelog (convert MR ids to urls: replace `!([0-9][0-9][0-9][0-9])` with `[!$1](https://gitlab.opengeosys.org/ogs/ogs/-/merge_requests/$1)` and `#([0-9][0-9][0-9][0-9])` with `[#$1](https://gitlab.opengeosys.org/ogs/ogs/-/issues/$1)`)
+- Add a link to the (upcoming) Doxygen documentation for this tag in `Documentation/mainpage.dox.in` (with `v`-prefix)
+- Update `[docs-release]`-link in `README.md` to the new tag (with `v`-prefix)
+- Add a redirect in `scripts/doc/_redirects`
 - Create a tag and push
 - A new release is automatically created on GitLab
   - Fill in the release notes from the Wiki
@@ -21,4 +24,10 @@ weight = 1051
 - Create a release on GitHub mirror (`ufz/ogs`)
 - Check if a [Zenodo release](https://zenodo.org/account/settings/github/repository/ufz/ogs#) is automatically issued
 - Issue a scan on [Software Heritage Archive](https://archive.softwareheritage.org/browse/origin/directory/?origin_url=https://gitlab.opengeosys.org/ogs/ogs.git)
+- Create bugfix branch
+  - Create new netlify site (in an empty directory)
+    - `netlify init`
+    - `# [ENTER]`
+    - `# ogs-doxygen-v6-3-3`
+  - Create branch from `master` with name `v[TAG]` and push
 - Create a discourse announcement post
-- 
GitLab