From fbb350aacc696db090110f7a72c346cd5ee260f4 Mon Sep 17 00:00:00 2001 From: Marc Wrobel Date: Sat, 7 Oct 2023 11:25:06 +0200 Subject: [PATCH] [jira] Add release automation --- src/jira.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/jira.py diff --git a/src/jira.py b/src/jira.py new file mode 100644 index 00000000..d7c100fa --- /dev/null +++ b/src/jira.py @@ -0,0 +1,36 @@ +from requests_html import HTMLSession +from common import endoflife +from datetime import datetime + +"""Fetch Jira versions with their dates from the Atlassian Website. + +This script is using requests-html (https://requests-html.kennethreitz.org/) +because the page needs JavaScript to render correctly. +""" + +PRODUCT = 'jira' +URL = 'https://www.atlassian.com/software/jira/update' + + +def parse_date(text): + return datetime.strptime(text, "%d-%b-%Y").strftime("%Y-%m-%d") + + +print(f"::group::{PRODUCT}") + +session = HTMLSession() +r = session.get(URL) +r.html.render(sleep=1, scrolldown=3) + +versions = {} +for version_block in r.html.find('.versions-list'): + version = version_block.find('a.product-versions', first=True).attrs['data-version'] + date = parse_date(version_block.find('.release-date', first=True).text) + print(f"{version}: {date}") + versions[version] = date + +endoflife.write_releases(PRODUCT, dict( + # sort by date then version (asc) + sorted(versions.items(), key=lambda x: (x[1], x[0])) +)) +print("::endgroup::")