2121# Pinned versions for the resolvers. See use at the bottom.
2222KEEPALIVED_VERSION = "2.3"
2323SOCAT_VERSION = "1"
24- HAPROXY_VERSION = "2.8 "
24+ HAPROXY_VERSION = "3.2 "
2525LUA_VERSION = "5.4"
2626PCRE_VERSION = "10"
2727HATOP_VERSION = "0"
@@ -150,6 +150,12 @@ def fetch_latest_release(self) -> Release:
150150 """
151151 raise NotImplementedError
152152
153+ def get_release_notes (self ) -> str :
154+ """
155+ Obtain changelog for the given current and latest release difference. This is useful to attach to the PR.
156+ """
157+ raise NotImplementedError
158+
153159 def remove_current_blob (self ):
154160 current_blob_path = f"{ self .package } /{ self .name } -{ self .current_version } .tar.gz"
155161 if self ._check_blob_exists (current_blob_path ):
@@ -183,8 +189,8 @@ def open_pr_exists(self) -> bool:
183189 prs_exist = False
184190
185191 for pr in self .remote_repo .get_pulls (
186- state = "open" , base = PR_BASE , head = f"{ PR_ORG } :{ self .pr_branch } "
187- ): # theoretically there shold never be more than one open PR, print them anyways
192+ state = "open" , base = PR_BASE , head = f"{ PR_ORG } :{ self .pr_branch } "
193+ ): # theoretically there should never be more than one open PR, print them anyways
188194 print (f"Open { self .pr_branch } PR exists: { pr .html_url } " )
189195 prs_exist = True
190196 return prs_exist
@@ -196,8 +202,8 @@ def create_pr(self):
196202 Automatic bump from version { self .current_version } to version { self .latest_release .version } , downloaded from { self .latest_release .url } .
197203
198204 After merge, consider releasing a new version of haproxy-boshrelease.
199- """
200- )
205+ """ ) + self . get_release_notes ()
206+
201207 if not DRY_RUN :
202208 self ._create_branch (self .remote_repo , self .pr_branch )
203209
@@ -285,6 +291,9 @@ def get_release_download_url(rel):
285291
286292 return latest_release
287293
294+ def get_release_notes (self ) -> str :
295+ return ""
296+
288297
289298@dataclass
290299class WebLinkDependency (Dependency ):
@@ -320,6 +329,9 @@ def fetch_latest_release(self) -> Release:
320329
321330 raise Exception (f"Failed to get latest { self .name } version from { self .root_url } " )
322331
332+ def get_release_notes (self ) -> str :
333+ return ""
334+
323335
324336@dataclass
325337class HaproxyDependency (Dependency ):
@@ -344,6 +356,80 @@ def fetch_latest_release(self) -> Release:
344356 version .parse (latest_version ),
345357 )
346358
359+ # Parse, validate and split version into parts
360+ def _parse_and_split_version (self , version ):
361+ version_parts = version .split ('.' )
362+ if len (version_parts ) < 3 :
363+ raise Exception (f"Expected version with 3 semver segments (major.minor.patch), got less: { version } ." )
364+ return version_parts [0 ], version_parts [1 ], version_parts [2 ]
365+
366+ # Returns normalized versions for changelog comparison
367+ def _get_comparison_versions (self , current_version , latest_version ):
368+ comparison_current = str (current_version )
369+ comparison_latest = str (latest_version )
370+
371+ current_major , current_minor , current_patch = self ._parse_and_split_version (comparison_current )
372+ latest_major , latest_minor , latest_patch = self ._parse_and_split_version (comparison_latest )
373+
374+ # Major version jump adjustment to the zero version
375+ if int (latest_major ) > int (current_major ):
376+ comparison_current = f"{ current_major } .{ current_minor } .0"
377+
378+ return comparison_current , comparison_latest
379+
380+ def get_release_notes (self ) -> str :
381+ current_version = self .current_version
382+ latest_version = self .latest_release .version
383+
384+ if (current_version == latest_version ):
385+ raise Exception (f"""Changelog requested but current and latest versions are the same: { current_version } """ )
386+
387+ releaseNote = textwrap .dedent (f"""
388+ [Changelog for HAProxy { latest_version } ](https://www.haproxy.org/download/{ HAPROXY_VERSION } /src/CHANGELOG).
389+
390+ Please also check list of [known open bugs for HAProxy { latest_version } ](https://www.haproxy.org/bugs/bugs-{ latest_version } .html).
391+
392+ The developer's summary for this release can be found in [the Announcement post for the HAProxy { latest_version } release](https://www.mail-archive.com/search?l=haproxy%40formilux.org&q=announce+subject%3A%22[ANNOUNCE]+haproxy-{ latest_version } %22+-subject%3A%22re:%22).
393+ """ )
394+
395+ wget (f"""https://www.haproxy.org/download/{ HAPROXY_VERSION } /src/CHANGELOG""" , "HAPROXY-CHANGELOG" )
396+ with open ('HAPROXY-CHANGELOG' , 'r' ) as file :
397+ releaseNote += textwrap .dedent (f"""
398+ <details>
399+
400+ <summary>HAPROXY CHANGELOG between { latest_version } and { current_version } </summary>
401+
402+ ```
403+ """ )
404+
405+ # Get normalized versions for comparison
406+ comparison_current , comparison_latest = self ._get_comparison_versions (current_version , latest_version )
407+
408+ startCopy = False
409+ for line in file :
410+ if (line .endswith (comparison_latest + "\n " )): # Start copying from latest version head
411+ startCopy = True
412+ if (line .endswith (comparison_current + "\n " )): # Stop when reaching current version
413+ break
414+ if not startCopy :
415+ continue
416+ releaseNote += line
417+ # PR body length is limited by 65536 characters, truncating the change log to 60000 to avoid a validation error
418+ releaseNoteLimit = 60000
419+ if len (releaseNote ) > releaseNoteLimit :
420+ releaseNote = releaseNote [:releaseNoteLimit ] + textwrap .dedent (f"""
421+
422+ Change log was trimmed to { releaseNoteLimit } characters. Please see the changelog file for the full change log.
423+ """ )
424+
425+ releaseNote += textwrap .dedent (f"""
426+ ```
427+
428+ </details>""" )
429+
430+ return releaseNote
431+
432+
347433
348434def wget (url : str , path : str , auth : Optional [Tuple [str , str ]] = None ):
349435 """
@@ -454,4 +540,4 @@ def main() -> None:
454540
455541
456542if __name__ == "__main__" :
457- main ()
543+ main ()
0 commit comments