def collect_changelog(repo: Repository, milestone: Milestone):
    print(f"Collecting changelog issues for `{milestone.title}` milestone")

    changelog = Changelog(milestone.number)
    issues = repo.get_issues(milestone=milestone, state="all")

    comment_pattern = re.compile("<!--.*-->", re.RegexFlag.DOTALL)
    changelog_description_pattern = re.compile("[Cc]hangelog:\\s*(?P<description>([^\n]+\n?)*)")
    for issue in issues:
        if issue.pull_request is None:
            continue
        labels: Set[str] = set(map(lambda l: l.name, issue.labels))
        if len(labels) == 0:
            continue

        if issue.body is not None:
            issue_text = re.sub(comment_pattern, "", issue.body).replace("\r\n", "\n")
        else:
            issue_text = ""
        result = re.search(changelog_description_pattern, issue_text)
        if result is not None:
            description = result.group("description").strip().rstrip(".")
        else:
            description = issue.title
        changelog_item = ChangelogItem(issue.number, description, issue.user.login)
        for label in labels:
            changelog.add_item(label, changelog_item)

    return changelog