output source data for Linux downloads on the website during deployment
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 6 May 2021 02:59:30 +0000 (19:59 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 12 May 2021 14:47:23 +0000 (07:47 -0700)
Commit 1b218752f5b6a1e661e158337fc1b976424fc6a0 of the website repository¹
changed how Linux downloads appear on the website to be driven by a JSON data
file. This commit updates the deployment script to produce this file for a
release as a CI job artifact. Related to #1979.

¹ https://gitlab.com/graphviz/graphviz.gitlab.io

.gitlab-ci.yml
ci/deploy.py

index d1873f71c2cb1bbbebdbae18d601625ec490b039..32032b15d1bfb2fc197bd90a5e83d6b9c746a331 100644 (file)
@@ -837,6 +837,11 @@ deployment:
     # do not run this job for MRs, developer’s forks, etc.
     only:
         - main@graphviz/graphviz
+    artifacts:
+        when: on_success
+        expire_in: 1 week
+        paths:
+            - graphviz-*.json
 
 .docker_template: &docker_definition
   image: docker:stable
index 9e17dcdce27d9c2a44ad79b62e254895b24f93df..ce7d560efe4a75d60addc5ceba65219318b5d6bd 100644 (file)
@@ -153,6 +153,12 @@ def main(args: List[str]) -> int:
   # list of assets we have uploaded
   assets: List[str] = []
 
+  # data for the website’s download page
+  webdata = {
+    "version":f"graphviz-{options.version}",
+    "archives":[],
+  }
+
   for tarball in (f"graphviz-{gv_version}.tar.gz",
                   f"graphviz-{gv_version}.tar.xz"):
 
@@ -160,10 +166,18 @@ def main(args: List[str]) -> int:
       log.error(f"source {tarball} not found")
       return -1
 
+    webentry = {"format":os.path.splitext(tarball)[-1][1:]}
+
     # accrue the source tarball and accompanying checksum(s)
-    assets.append(upload(package_version, tarball))
+    url = upload(package_version, tarball)
+    assets.append(url)
+    webentry["url"] = url
     for check in checksum(tarball):
-      assets.append(upload(package_version, check))
+      url = upload(package_version, check)
+      assets.append(url)
+      webentry[os.path.splitext(check)[-1][1:]] = url
+
+    webdata["archives"].append(webentry)
 
   for stem, _, leaves in os.walk("Packages"):
     for leaf in leaves:
@@ -202,6 +216,11 @@ def main(args: List[str]) -> int:
   # create the release
   subprocess.check_call(cmd)
 
+  # output JSON data for the website
+  log.info(f"dumping {webdata} to graphviz-{options.version}.json")
+  with open(f"graphviz-{options.version}.json", "wt") as f:
+    json.dump(webdata, f, indent=2)
+
   return 0
 
 if __name__ == "__main__":