browsertrix/scripts/generate-helm-index.py
Ilya Kreymer b574f00d2b
Add Repository Index + Chart Rename + Docs Rename (#1708)
Repository Index: Generate an index.yaml in ./docx/helm-repo/index.yaml
to allow for browsertrix to be a helm repository.
docs: rename docs.browsertrix.cloud -> docs.browsertrix.com
docs: update deployment doc to mention helm repo as preferred way to
install
docs build action: generate repository index in GH action
publish action: update auto-generated message to mention installing from
the repo.

---------
Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
2024-04-21 09:42:25 -07:00

57 lines
1.3 KiB
Python

import requests
import json
import hashlib
import yaml
desc = "A chart for Browsertrix integrated web archiving system"
URL = "https://api.github.com/repos/webrecorder/browsertrix/releases"
source_prefix = "https://github.com/webrecorder/browsertrix/tree/"
home = "https://github.com/webrecorder/browsertrix"
def compute_hash(url):
h = hashlib.sha256()
with requests.get(url, stream=True) as resp:
for chunk in resp.iter_content():
h.update(chunk)
return h.hexdigest()
def main():
result = requests.get(URL)
index_releases = []
for release in result.json():
asset = release["assets"][0]
url = asset["browser_download_url"]
tag = release["tag_name"]
data = {
"apiVersion": "v2",
"created": asset["created_at"],
"name": release["name"],
"digest": compute_hash(url),
"description": desc,
"urls": [url],
"sources": [source_prefix + tag],
"type": "application",
"home": home,
"appVersion": tag.replace("v", ""),
"version": tag.replace("v", "")
}
index_releases.append(data)
root = {
"apiVersion": "v1",
"entries": {
"browsertrix": index_releases
}
}
print(yaml.dump(root))
main()