[redhat-satellite] Add automation (closes #82)

This commit is contained in:
Marc Wrobel
2023-06-16 22:43:05 +02:00
parent 9ba96a3cb8
commit ed2290189b
2 changed files with 40 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ Common Release Data for various projects in a consumable format. Current format
## Currently Updated
As of 2023-06-25, 159 of the 232 products tracked by endoflife.date have automatically tracked releases:
As of 2023-06-25, 160 of the 232 products tracked by endoflife.date have automatically tracked releases:
| Product | Permalink | Auto | Method |
|--------------------------------------|-------------------------------|------|-----------------|
@@ -208,7 +208,7 @@ As of 2023-06-25, 159 of the 232 products tracked by endoflife.date have automat
| React | `/react` | ✔️ | npm |
| Red Hat Enterprise Linux | `/rhel` | ❌ | n/a |
| Red Hat OpenShift | `/red-hat-openshift` | ❌ | n/a |
| Red Hat Satellite | `/redhat-satellite` | | n/a |
| Red Hat Satellite | `/redhat-satellite` | ✔️ | custom |
| Redis | `/redis` | ✔️ | git |
| Redmine | `/redmine` | ✔️ | git |
| Rocky Linux | `/rocky-linux` | ✔️ | distrowatch |

38
src/redhat-satellite.py Normal file
View File

@@ -0,0 +1,38 @@
import re
from bs4 import BeautifulSoup
from common import endoflife
"""Fetch versions with their dates from access.redhat.com.
A few of the older versions, such as 'Satellite 6.1 GA Release (Build 6.1.1)',
were ignored because too hard to parse.
"""
URL = "https://access.redhat.com/articles/1365633"
# https://regex101.com/r/m8aWXG/1
regex = r"^Satellite (?P<version>\d+\.\d+\.\d+([.-]\d+)?) ([Uu]pdate|[Rr]elease)$"
print("::group::redhat-satellite")
response = endoflife.fetch_url(URL)
soup = BeautifulSoup(response, features="html5lib")
versions = {}
for table in soup.findAll("tbody"):
for tr in table.findAll("tr"):
td_list = tr.findAll("td")
# Versions x.y GA are transformed to x.y.0
version = td_list[0].get_text().replace(' GA', '.0').strip()
m = re.match(regex, version)
if m:
# Versions a.b.c-d are transformed to a.b.c.d
version = m["version"].replace('-', '.')
date = td_list[1].get_text().strip()
versions[version] = date
print(f"{version}: {date}")
endoflife.write_releases('redhat-satellite', dict(
# sort by date then version (desc)
sorted(versions.items(), key=lambda x: (x[1], x[0]), reverse=True)
))
print("::endgroup::")