diff mbox series

docs/website: auto-generate the downloads page

Message ID 20251013142140.68026-1-titouan.christophe@mind.be
State New
Headers show
Series docs/website: auto-generate the downloads page | expand

Commit Message

Titouan Christophe Oct. 13, 2025, 2:21 p.m. UTC
Separate the releases data from its templating on the website.
Each line in the table on the releases page has the same information
repeated multiple times, such as the release tag (like "2025.02.7") that
is present in the text and multiple links.

Consequently, when publishing a new version of Buildroot, it is likely
that we're using search & replace in the HTML file to update them all
at once. However, other fields, such as the release date, may be
forgotten in the process, as it happened recently [1]. Moreover, the extra
surrounding markup makes it more difficult to spot all information to
be updated at a glance.

To make things easier, let's define the releases data in a concise json
file, and generate the downloads page from it with a python script.
This also makes it easier to update the templating if needed.

[1] f32e6aa226ccbc9a53a47c736a13e57bcc78dc67

Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
---
 docs/website/download.html      | 116 +-------------------------------
 docs/website/releases.html      |  94 ++++++++++++++++++++++++++
 docs/website/releases.json      |  25 +++++++
 utils/generate-website-releases |  72 ++++++++++++++++++++
 4 files changed, 192 insertions(+), 115 deletions(-)
 create mode 100644 docs/website/releases.html
 create mode 100644 docs/website/releases.json
 create mode 100755 utils/generate-website-releases
diff mbox series

Patch

diff --git a/docs/website/download.html b/docs/website/download.html
index d5b849ca9a..08c53bc3f1 100644
--- a/docs/website/download.html
+++ b/docs/website/download.html
@@ -7,121 +7,7 @@ 
   <div class="panel panel-primary">
     <div class="panel-heading">Download</div>
     <div class="panel-body">
-      <table class="table">
-        <tr>
-          <td></td>
-          <th>Series</th>
-          <th>End of Life</th>
-          <th>Latest release</th>
-          <th>Latest release date</th>
-          <th colspan="2">Downloads</td>
-        </tr>
-<!--
-        <tr>
-          <th>Candidate</th>
-          <th>2025.08.x</th>
-          <td>December 2025</td>
-          <td>
-            2025.08-rc3<br/>
-            <a href="https://gitlab.com/buildroot.org/buildroot/-/blob/2025.08-rc3/CHANGES">
-              Changelog
-            </a>
-          </td>
-          <td>2025-08-28</td>
-          <td>
-            <a href="/downloads/buildroot-2025.08-rc3.tar.gz">
-              <img src="images/zip.png" width="24" alt="">
-              .tar.gz
-            </a><br/>
-            <a href="/downloads/buildroot-2025.08-rc3.tar.gz.sign">[PGP sig]</a>
-          </td>
-          <td>
-            <a href="/downloads/buildroot-2025.08-rc3.tar.xz">
-              <img src="images/package.png" width="24" alt="">
-              .tar.xz
-            </a><br/>
-            <a href="/downloads/buildroot-2025.08-rc3.tar.xz.sign">[PGP sig]</a>
-          </td>
-        </tr>
--->
-        <tr>
-          <th>Stable</th>
-          <th>2025.08.x</th>
-          <td>December 2025</td>
-          <td>
-            2025.08.1<br/>
-            <a href="https://gitlab.com/buildroot.org/buildroot/-/blob/2025.08.1/CHANGES">
-              Changelog
-            </a>
-          </td>
-          <td>2025-10-11</td>
-          <td>
-            <a href="/downloads/buildroot-2025.08.1.tar.gz">
-              <img src="images/zip.png" width="24" alt="">
-              .tar.gz
-            </a><br/>
-            <a href="/downloads/buildroot-2025.08.1.tar.gz.sign">[PGP sig]</a>
-          </td>
-          <td>
-            <a href="/downloads/buildroot-2025.08.1.tar.xz">
-              <img src="images/package.png" width="24" alt="">
-              .tar.xz
-            </a><br/>
-            <a href="/downloads/buildroot-2025.08.1.tar.xz.sign">[PGP sig]</a>
-          </td>
-        </tr>
-          <th>Stable (EOL)</th>
-          <th>2025.05.x</th>
-          <td>September 2025</td>
-          <td>
-            2025.05.3<br/>
-            <a href="https://gitlab.com/buildroot.org/buildroot/-/blob/2025.05.3/CHANGES">
-              Changelog
-            </a>
-          </td>
-          <td>2025-10-11</td>
-          <td>
-            <a href="/downloads/buildroot-2025.05.3.tar.gz">
-              <img src="images/zip.png" width="24" alt="">
-              .tar.gz
-            </a><br/>
-            <a href="/downloads/buildroot-2025.05.3.tar.gz.sign">[PGP sig]</a>
-          </td>
-          <td>
-            <a href="/downloads/buildroot-2025.05.3.tar.xz">
-              <img src="images/package.png" width="24" alt="">
-              .tar.xz
-            </a><br/>
-            <a href="/downloads/buildroot-2025.05.3.tar.xz.sign">[PGP sig]</a>
-          </td>
-        </tr>
-        <tr>
-          <th>Long-term support</th>
-          <th>2025.02.x</th>
-          <td>March 2028</td>
-          <td>
-            2025.02.7<br/>
-            <a href="https://gitlab.com/buildroot.org/buildroot/-/blob/2025.02.7/CHANGES">
-              Changelog
-            </a>
-          </td>
-          <td>2025-10-11</td>
-          <td>
-            <a href="/downloads/buildroot-2025.02.7.tar.gz">
-              <img src="images/zip.png" width="24" alt="">
-              .tar.gz
-            </a><br/>
-            <a href="/downloads/buildroot-2025.02.7.tar.gz.sign">[PGP sig]</a>
-          </td>
-          <td>
-            <a href="/downloads/buildroot-2025.02.7.tar.xz">
-              <img src="images/package.png" width="24" alt="">
-              .tar.xz
-            </a><br/>
-            <a href="/downloads/buildroot-2025.02.7.tar.xz.sign">[PGP sig]</a>
-          </td>
-        </tr>
-      </table>
+      <!--#include file="releases.html" -->
 
       This and earlier releases (and their PGP signatures) can always be downloaded from
       <a href="/downloads/">http://buildroot.net/downloads/</a>.
diff --git a/docs/website/releases.html b/docs/website/releases.html
new file mode 100644
index 0000000000..5f95f334da
--- /dev/null
+++ b/docs/website/releases.html
@@ -0,0 +1,94 @@ 
+
+<!-- This fragment was generated from releases.json
+     See utils/generate-website-releases -->
+<table class="table">
+    <tr>
+        <td></td>
+        <th>Series</th>
+        <th>End of Life</th>
+        <th>Latest release</th>
+        <th>Latest release date</th>
+        <th colspan="2">Downloads</td>
+    </tr>
+
+    <tr>
+        <th>Stable</th>
+        <th>2025.08.x</th>
+        <td>December 2025</td>
+        <td>
+            2025.08.1<br/>
+            <a href="https://gitlab.com/buildroot.org/buildroot/-/blob/2025.08.1/CHANGES">
+                Changelog
+            </a>
+        </td>
+        <td>2025-10-11</td>
+        <td>
+            <a href="/downloads/buildroot-2025.08.1.tar.gz">
+                <img src="images/zip.png" width="24" alt="">
+                .tar.gz
+            </a><br/>
+            <a href="/downloads/buildroot-2025.08.1.tar.gz.sign">[PGP sig]</a>
+        </td>
+        <td>
+            <a href="/downloads/buildroot-2025.08.1.tar.xz">
+                <img src="images/package.png" width="24" alt="">
+                .tar.xz
+            </a><br/>
+            <a href="/downloads/buildroot-2025.08.1.tar.xz.sign">[PGP sig]</a>
+        </td>
+    </tr>
+
+    <tr>
+        <th>Stable (EOL)</th>
+        <th>2025.05.x</th>
+        <td>September 2025</td>
+        <td>
+            2025.05.3<br/>
+            <a href="https://gitlab.com/buildroot.org/buildroot/-/blob/2025.05.3/CHANGES">
+                Changelog
+            </a>
+        </td>
+        <td>2025-10-11</td>
+        <td>
+            <a href="/downloads/buildroot-2025.05.3.tar.gz">
+                <img src="images/zip.png" width="24" alt="">
+                .tar.gz
+            </a><br/>
+            <a href="/downloads/buildroot-2025.05.3.tar.gz.sign">[PGP sig]</a>
+        </td>
+        <td>
+            <a href="/downloads/buildroot-2025.05.3.tar.xz">
+                <img src="images/package.png" width="24" alt="">
+                .tar.xz
+            </a><br/>
+            <a href="/downloads/buildroot-2025.05.3.tar.xz.sign">[PGP sig]</a>
+        </td>
+    </tr>
+
+    <tr>
+        <th>Long-term support</th>
+        <th>2025.02.x</th>
+        <td>March 2028</td>
+        <td>
+            2025.02.7<br/>
+            <a href="https://gitlab.com/buildroot.org/buildroot/-/blob/2025.02.7/CHANGES">
+                Changelog
+            </a>
+        </td>
+        <td>2025-10-11</td>
+        <td>
+            <a href="/downloads/buildroot-2025.02.7.tar.gz">
+                <img src="images/zip.png" width="24" alt="">
+                .tar.gz
+            </a><br/>
+            <a href="/downloads/buildroot-2025.02.7.tar.gz.sign">[PGP sig]</a>
+        </td>
+        <td>
+            <a href="/downloads/buildroot-2025.02.7.tar.xz">
+                <img src="images/package.png" width="24" alt="">
+                .tar.xz
+            </a><br/>
+            <a href="/downloads/buildroot-2025.02.7.tar.xz.sign">[PGP sig]</a>
+        </td>
+    </tr>
+</table>
\ No newline at end of file
diff --git a/docs/website/releases.json b/docs/website/releases.json
new file mode 100644
index 0000000000..476abb9963
--- /dev/null
+++ b/docs/website/releases.json
@@ -0,0 +1,25 @@ 
+{
+  "releases": [
+    {
+      "series": "2025.08.x",
+      "name": "Stable",
+      "planned_eol": "December 2025",
+      "latest": "2025.08.1",
+      "latest_date": "2025-10-11"
+    },
+    {
+      "series": "2025.05.x",
+      "name": "Stable (EOL)",
+      "planned_eol": "September 2025",
+      "latest": "2025.05.3",
+      "latest_date": "2025-10-11"
+    },
+    {
+      "series": "2025.02.x",
+      "name": "Long-term support",
+      "planned_eol": "March 2028",
+      "latest": "2025.02.7",
+      "latest_date": "2025-10-11"
+    }
+  ]
+}
diff --git a/utils/generate-website-releases b/utils/generate-website-releases
new file mode 100755
index 0000000000..4ff62df121
--- /dev/null
+++ b/utils/generate-website-releases
@@ -0,0 +1,72 @@ 
+#!/usr/bin/env python3
+
+"""
+Generate the download HTML page for the website from releases.json that lists
+all actively maintained releases
+"""
+
+import json
+from pathlib import Path
+from sys import argv
+
+THIS_SCRIPT = Path(argv[0]).absolute()
+BUILDROOT_DIR = THIS_SCRIPT.parent.parent
+WEBSITE = BUILDROOT_DIR / "docs" / "website"
+
+COMMENT_HEADER = f"""
+<!-- This fragment was generated from releases.json
+     See {THIS_SCRIPT.relative_to(BUILDROOT_DIR)} -->
+"""
+
+TABLE_HEADER = """
+    <tr>
+        <td></td>
+        <th>Series</th>
+        <th>End of Life</th>
+        <th>Latest release</th>
+        <th>Latest release date</th>
+        <th colspan="2">Downloads</td>
+    </tr>
+"""
+
+TABLE_ROW = """
+    <tr>
+        <th>{name}</th>
+        <th>{series}</th>
+        <td>{planned_eol}</td>
+        <td>
+            {latest}<br/>
+            <a href="https://gitlab.com/buildroot.org/buildroot/-/blob/{latest}/CHANGES">
+                Changelog
+            </a>
+        </td>
+        <td>{latest_date}</td>
+        <td>
+            <a href="/downloads/buildroot-{latest}.tar.gz">
+                <img src="images/zip.png" width="24" alt="">
+                .tar.gz
+            </a><br/>
+            <a href="/downloads/buildroot-{latest}.tar.gz.sign">[PGP sig]</a>
+        </td>
+        <td>
+            <a href="/downloads/buildroot-{latest}.tar.xz">
+                <img src="images/package.png" width="24" alt="">
+                .tar.xz
+            </a><br/>
+            <a href="/downloads/buildroot-{latest}.tar.xz.sign">[PGP sig]</a>
+        </td>
+    </tr>
+"""
+
+with (WEBSITE / "releases.json").open() as f:
+    print(f"Reading {f.name}...")
+    releases_data = json.load(f)
+
+with (WEBSITE / "releases.html").open("w") as f:
+    f.write(COMMENT_HEADER)
+    f.write('<table class="table">')
+    f.write(TABLE_HEADER)
+    for r in releases_data["releases"]:
+        f.write(TABLE_ROW.format(**r))
+    f.write("</table>")
+    print(f"Wrote {f.name}")