From 7e03153f8ed63e276c007ecc04a50927be58225a Mon Sep 17 00:00:00 2001
From: Justin Ross
Date: Fri, 15 Dec 2023 13:55:52 -0500
Subject: [PATCH] Script the procedure for updating the site for new releases,
and update for 1.5.1
---
.plano.py | 70 ++++++++++++++
README.md | 14 ++-
config/config.py | 20 +++-
config/releases.md.in | 36 +++++++
data/releases.json | 199 +++++++++++++++++++++++++++++++++++++++
docs/index.html | 2 +-
docs/install/index.html | 14 +--
docs/releases/index.html | 77 +++++++--------
input/releases/index.md | 75 +++++++--------
9 files changed, 417 insertions(+), 90 deletions(-)
create mode 100644 config/releases.md.in
create mode 100644 data/releases.json
diff --git a/.plano.py b/.plano.py
index cb501611..18287255 100644
--- a/.plano.py
+++ b/.plano.py
@@ -19,6 +19,8 @@
from transom.planocommands import *
+import datetime as _datetime
+
site.output_dir = "docs"
@command
@@ -125,6 +127,65 @@ def generate_examples(output_file="input/examples/index.html.in"):
write(output_file, "\n".join(out))
+@command
+def generate_releases(output_file="input/releases/index.md"):
+ """
+ Generate the release index using data from GitHub
+ """
+
+ _update_release_data()
+
+ releases = read_json("data/releases.json")
+ latest_release_version = releases["latest_release"]["version"]
+ out = list()
+
+ for release in releases["releases"]:
+ version = release["version"]
+
+ if version == latest_release_version:
+ continue
+
+ url = release["url"]
+ date = parse_timestamp(release["date"])
+
+ out.append(f"* [{version}]({url}) - {date.day} {date.strftime('%B %Y')}")
+
+ releases = "\n".join(out)
+ markdown = read("config/releases.md.in").replace("@releases@", releases)
+ output_file = get_absolute_path(output_file)
+
+ write(output_file, markdown)
+
+def _update_release_data():
+ releases = http_get_json("https://api.github.com/repos/skupperproject/skupper/releases?per_page=100")
+ latest_release = http_get_json("https://api.github.com/repos/skupperproject/skupper/releases/latest")
+
+ data = dict()
+
+ latest_release_tag = latest_release["tag_name"]
+
+ data["latest_release"] = {
+ "version": latest_release_tag,
+ "url": "https://github.com/skupperproject/skupper/releases/tag/{latest_release_tag}",
+ "date": latest_release["published_at"],
+ }
+
+ data["releases"] = list()
+
+ for release in releases:
+ if release["prerelease"] or release["draft"]:
+ continue
+
+ release_tag = release["tag_name"]
+
+ data["releases"].append({
+ "version": release_tag,
+ "url": f"https://github.com/skupperproject/skupper/releases/tag/{release_tag}",
+ "date": release["published_at"],
+ })
+
+ write_json("data/releases.json", data)
+
@command
def test():
render()
@@ -136,3 +197,12 @@ def test():
run("cat docs/install.sh | sh", shell=True)
generate_docs(output_dir=d)
+
+def parse_timestamp(timestamp, format="%Y-%m-%dT%H:%M:%SZ"):
+ if timestamp is None:
+ return None
+
+ dt = _datetime.datetime.strptime(timestamp, format)
+ dt = dt.replace(tzinfo=_datetime.timezone.utc)
+
+ return dt
diff --git a/README.md b/README.md
index 2ecf49a8..9732cdc5 100644
--- a/README.md
+++ b/README.md
@@ -54,8 +54,12 @@ The process of publishing these docs to the Skupper website uses
## Updating the site for new Skupper releases
-1. Update the `skupper_release` and `skupper_release_date` variables
- in `config/config.py`.
-2. Add an entry for the previous release to `releases/index.md` in the
- "Previous releases" section.
-3. Run `plano render --force` to update the site.
+Run the `generate-releases` command:
+
+~~~ console
+./plano generate-releases
+./plano render --force
+~~~
+
+This fetches release data from GitHub and updates the site for new
+releases.
diff --git a/config/config.py b/config/config.py
index 12f3fe0a..113d6a3a 100644
--- a/config/config.py
+++ b/config/config.py
@@ -1,6 +1,22 @@
+from plano import *
+
+import datetime as _datetime
+
def path_nav(page):
links = " › ".join(list(page.path_nav_links)[1:])
return f""
-skupper_release = "1.5.0"
-skupper_release_date = "10 November 2023"
+def _parse_timestamp(timestamp, format="%Y-%m-%dT%H:%M:%SZ"):
+ if timestamp is None:
+ return None
+
+ dt = _datetime.datetime.strptime(timestamp, format)
+ dt = dt.replace(tzinfo=_datetime.timezone.utc)
+
+ return dt
+
+_latest_release = read_json("data/releases.json")["latest_release"]
+_latest_release_date = _parse_timestamp(_latest_release["date"])
+
+skupper_release = _latest_release["version"]
+skupper_release_date = f"{_latest_release_date.day} {_latest_release_date.strftime('%B %Y')}"
diff --git a/config/releases.md.in b/config/releases.md.in
new file mode 100644
index 00000000..39bf01e4
--- /dev/null
+++ b/config/releases.md.in
@@ -0,0 +1,36 @@
+---
+title: Releases
+---
+
+# Skupper releases
+
+## The latest release
+
+[Skupper {{skupper_release}}][release-page] was released on {{skupper_release_date}}.
+
+For Linux or the Mac, use the [install script][install-script] to
+download and extract the Skupper command:
+
+
curl https://skupper.io/install.sh | sh
+
+The script installs the command under your home directory. It prompts
+you to add the command to your path if necessary.
+
+For Windows and other installation options, see [Installing
+Skupper](/install/index.html).
+
+[release-page]: https://github.com/skupperproject/skupper/releases/tag/{{skupper_release}}
+[install-script]: https://github.com/skupperproject/skupper-website/blob/main/docs/install.sh
+
+## Previous releases
+
+
Use tar or unzip to extract the command from the release archive:
Linux or Mac
-
tar -xf skupper-cli-1.5.0-linux-amd64.tgz
+
tar -xf skupper-cli-1.5.1-linux-amd64.tgz
Windows
-
unzip skupper-cli-1.5.0-windows-amd64.zip
+
unzip skupper-cli-1.5.1-windows-amd64.zip
This produces an executable file named skupper in your current
directory.
Place the command on your path
@@ -123,7 +123,7 @@
Check the command
To test your installation, run the skupper version command. You
should see output like this:
$ skupper version
-client version 1.5.0
+client version 1.5.1
transport version not-found (no configuration has been provided)
controller version not-found (no configuration has been provided)