Module continuous_delivery_scripts.generate_news

Handles usage of towncrier for automated changelog generation and pyautoversion for versioning.

Functions

def main() ‑> None
Expand source code
def main() -> None:
    """Handle command line arguments to generate a version and changelog file."""
    parser = argparse.ArgumentParser(description="Versions the project.")
    parser.add_argument(
        "-t", "--release-type", help="type of release to perform", required=True, type=str, choices=CommitType.choices()
    )
    parser.add_argument("-v", "--verbose", action="count", default=0, help="Verbosity, by default errors are reported.")
    args = parser.parse_args()
    set_log_level(args.verbose)

    try:
        commit_type = CommitType.parse(args.release_type)
        is_new_version, new_version, version_elements = version_project(commit_type)
        version_to_print = determine_version_string(commit_type, new_version, version_elements)
        print(version_to_print)
    except Exception as e:
        log_exception(logger, e)
        sys.exit(1)

Handle command line arguments to generate a version and changelog file.

def version_project(commit_type: CommitType) ‑> Tuple[bool, str | None, Dict[str, str]]
Expand source code
def version_project(commit_type: CommitType) -> Tuple[bool, Optional[str], Dict[str, str]]:
    """Versions the project.

    Args:
        commit_type: states what is the type of the commit


    Returns:
        (is new version, the new version)
    """
    use_news_files = commit_type in [CommitType.BETA, CommitType.RELEASE]
    is_new_version, new_version, version_elements = calculate_version(commit_type, use_news_files, True)
    _generate_changelog(new_version, use_news_files)
    return is_new_version, new_version, version_elements

Versions the project.

Args
-----=
commit_type
states what is the type of the commit

Returns -----= (is new version, the new version)