diff mbox series

[4/5] doc: build using remote releases.json

Message ID 20260317-docs-releases-json-v1-4-492d0b256349@bootlin.com
State Accepted, archived
Commit b55497ab7e29eec398fe52359878a76b185e1af0
Headers show
Series Docs build cleanup and automations | expand

Commit Message

Antonin Godard March 17, 2026, 10:08 a.m. UTC
Like what was done for yocto-docs[1], build using the remote
releases.json file we can fetch from [2].

The file is downloaded if not present, and not re-downloaded for
subsequent builds. In case of fetch failure, fallback to default values.

[1]: https://git.yoctoproject.org/yocto-docs/commit/?id=5bebe38a808a33fea3deefc21dda39a35d90a7dd
[2]: https://dashboard.yoctoproject.org/releases.json

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 doc/.gitignore     |  1 +
 doc/Makefile       |  2 +-
 doc/setversions.py | 59 +++++++++++++++++++++++++++++++++++++++++++++---------
 3 files changed, 51 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/doc/.gitignore b/doc/.gitignore
index dee9494dcaf..1ee009c2012 100644
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -1,2 +1,3 @@ 
 _build/
 sphinx-static/switchers.js
+releases.json
diff --git a/doc/Makefile b/doc/Makefile
index 5e1632314c5..752f9b53b3e 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -27,7 +27,7 @@  publish: Makefile html singlehtml
 	sed -i -e 's@index.html#@singleindex.html#@g' $(BUILDDIR)/$(DESTDIR)/singleindex.html
 
 clean:
-	@rm -rf $(BUILDDIR) sphinx-static/switchers.js
+	@rm -rf $(BUILDDIR) sphinx-static/switchers.js releases.json
 
 # Catch-all target: route all unknown targets to Sphinx using the new
 # "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
diff --git a/doc/setversions.py b/doc/setversions.py
index 967a0ba5a64..bcc3194b63c 100755
--- a/doc/setversions.py
+++ b/doc/setversions.py
@@ -14,30 +14,69 @@ 
 #
 
 import itertools
+import json
+import os
 import re
 import subprocess
 import sys
 
+from urllib.request import urlopen, URLError
+
+# NOTE: the following variables contain default values in case we are not able to fetch
+# the releases.json file from https://dashboard.yoctoproject.org/releases.json
 DEVBRANCH = "2.18"
 LTSSERIES = ["2.8", "2.0"]
 ACTIVERELEASES = ["2.16"] + LTSSERIES
-
 YOCTO_MAPPING = {
     "2.18": "wrynose",
     "2.16": "whinlatter",
-    "2.12": "walnascar",
-    "2.10": "styhead",
     "2.8": "scarthgap",
-    "2.6": "nanbield",
-    "2.4": "mickledore",
-    "2.2": "langdale",
     "2.0": "kirkstone",
-    "1.52": "honister",
-    "1.50": "hardknott",
-    "1.48": "gatesgarth",
-    "1.46": "dunfell",
 }
 
+RELEASES_FROM_JSON = {}
+
+# Use the local releases.json file if found, fetch it from the dashboard otherwise
+releases_json_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "releases.json")
+try:
+    with open(releases_json_path, "r") as f:
+        RELEASES_FROM_JSON = json.load(f)
+except FileNotFoundError:
+    print("Fetching releases.json from https://dashboard.yoctoproject.org/releases.json...",
+          file=sys.stderr)
+    try:
+        with urlopen("https://dashboard.yoctoproject.org/releases.json") as r, \
+                open(releases_json_path, "w") as f:
+            RELEASES_FROM_JSON = json.load(r)
+            json.dump(RELEASES_FROM_JSON, f)
+    except URLError:
+        print("WARNING: tried to fetch https://dashboard.yoctoproject.org/releases.json "
+              "but failed, using default values for active releases", file=sys.stderr)
+        pass
+
+if RELEASES_FROM_JSON:
+    ACTIVERELEASES = []
+    DEVBRANCH = ""
+    LTSSERIES = []
+    YOCTO_MAPPING = {}
+
+    for release in RELEASES_FROM_JSON:
+        bb_ver = release["bitbake_version"]
+        if release["status"] == "Active Development":
+            DEVBRANCH = bb_ver
+        if release["series"] == "current":
+            ACTIVERELEASES.append(bb_ver)
+        if "LTS until" in release["status"]:
+            LTSSERIES.append(bb_ver)
+        if release["bitbake_version"]:
+            YOCTO_MAPPING[bb_ver] = release["release_codename"]
+
+    ACTIVERELEASES.remove(DEVBRANCH)
+
+print(f"ACTIVERELEASES calculated to be {ACTIVERELEASES}", file=sys.stderr)
+print(f"DEVBRANCH calculated to be {DEVBRANCH}", file=sys.stderr)
+print(f"LTSSERIES calculated to be {LTSSERIES}", file=sys.stderr)
+
 BB_RELEASE_TAG_RE = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+$")
 
 def get_current_version():