It may not be the best place for that (gha.py would have been better), but it's the shorter / faster way to do it for now. Moreover it now uses logging for writing the group. The logger format has been updated for this to work. This was done to fix issues on GitHub Action logs, where groups were declared after the logs.
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
import re
|
|
|
|
from common import dates, endoflife
|
|
from common.git import Git
|
|
|
|
"""Fetches Red Hat OpenShift versions from the documentation's git repository"""
|
|
|
|
VERSION_AND_DATE_PATTERN = re.compile(r"{product-title}\s(?P<version>\d+\.\d+\.\d+).*\n+Issued:\s(?P<date>\d{4}-\d\d-\d\d)$", re.MULTILINE)
|
|
|
|
product = endoflife.Product("red-hat-openshift")
|
|
git = Git("https://github.com/openshift/openshift-docs.git")
|
|
git.setup()
|
|
|
|
# only fetch v4+ branches, because the format was different in openshift v3
|
|
for branch in git.list_branches("refs/heads/enterprise-[4-9]*"):
|
|
version = branch.split("-")[1].replace(".", "-")
|
|
release_notes_filename = f"release_notes/ocp-{version}-release-notes.adoc"
|
|
git.checkout(branch, file_list=[release_notes_filename])
|
|
|
|
release_notes_file = git.repo_dir / release_notes_filename
|
|
if not release_notes_file.exists():
|
|
continue
|
|
|
|
with release_notes_file.open("rb") as f:
|
|
content = f.read().decode("utf-8")
|
|
for (version, date_str) in VERSION_AND_DATE_PATTERN.findall(content):
|
|
product.declare_version(version, dates.parse_date(date_str))
|
|
|
|
product.write()
|