[looker] Add release automation (#161)

Fetch Looker versions with their dates from the Google Cloud release notes RSS feed: https://cloud.google.com/feeds/looker-release-notes.xml.

Only version above 23.0 are retrieved, as prior version were not announced in the Google Cloud release notes.
This commit is contained in:
Marc Wrobel
2023-10-07 18:24:55 +02:00
parent 0108a2beb4
commit c6a7c4969d

42
src/looker.py Normal file
View File

@@ -0,0 +1,42 @@
import re
from bs4 import BeautifulSoup
from common import endoflife
from datetime import datetime, timezone
from xml.dom.minidom import parseString
"""Fetch Looker versions with their dates from the Google Cloud release notes RSS feed.
"""
PRODUCT = "looker"
URL = "https://cloud.google.com/feeds/looker-release-notes.xml"
ANNOUNCEMENT_PATTERN = re.compile(r"includes\s+the\s+following\s+changes", re.IGNORECASE)
VERSION_PATTERN = re.compile(r"Looker\s+(?P<version>\d+\.\d+)", re.IGNORECASE)
def parse_date(date_str):
return datetime.fromisoformat(date_str).astimezone(timezone.utc).strftime("%Y-%m-%d")
print(f"::group::{PRODUCT}")
versions = {}
response = endoflife.fetch_url(URL)
rss = parseString(response)
for item in rss.getElementsByTagName("entry"):
date = parse_date(item.getElementsByTagName("updated")[0].firstChild.nodeValue)
content = item.getElementsByTagName("content")[0].firstChild.nodeValue
soup = BeautifulSoup(content, features="html5lib")
announcement = soup.find(string=ANNOUNCEMENT_PATTERN)
if announcement:
m = re.search(VERSION_PATTERN, announcement.parent.get_text())
if m:
version = m.group("version")
versions[version] = date
print(f"{version}: {date}")
endoflife.write_releases(PRODUCT, dict(
# sort by date then version (desc)
sorted(versions.items(), key=lambda x: (x[1], x[0]), reverse=True)
))
print("::endgroup::")