def update_changelog(pom_file, is_increment):

    # Before doing anything, ensure that there is a changelog.md file sitting next to the pom file
    dirname = os.path.dirname(pom_file)
    changelog = os.path.join(dirname, "CHANGELOG.md")

    if os.path.isfile(changelog):
        tree = ET.parse(pom_file)
        xml_root = tree.getroot()
        xml_version = xml_root.find('{http://maven.apache.org/POM/4.0.0}version')
        version = xml_version.text

        script = os.path.join(".", "eng", "common", "scripts", "Update-ChangeLog.ps1")
        commands = [
            "pwsh",
            script,
            "--Version",
            version,
            "--ChangeLogPath",
            changelog,
            "--Unreleased:$true", # This update versions should never stamp in a release date so it will always be unreleased.
            "--ReplaceLatestEntryTitle:$" + str(not is_increment) # If this call is not a result of auto version increment then replace the latest entry with the current version
        ]
        # Run script to update change log
        run_check_call(commands, '.')
    else:
        print('There is no CHANGELOG.md file in {}, skipping update'.format(dirname))
Пример #2
0
def update_changelog(pom_file, is_increment, library_array):

    # Before doing anything, ensure that there is a changelog.md file sitting next to the pom file
    dirname = os.path.dirname(pom_file)
    changelog = os.path.join(dirname, "CHANGELOG.md")

    if os.path.isfile(changelog):
        tree = ET.parse(pom_file)
        xml_root = tree.getroot()
        xml_version = xml_root.find('{http://maven.apache.org/POM/4.0.0}version')
        version = xml_version.text
        xml_artifactId = xml_root.find('{http://maven.apache.org/POM/4.0.0}artifactId')
        xml_groupId = xml_root.find('{http://maven.apache.org/POM/4.0.0}groupId')
        library = xml_groupId.text + ":" + xml_artifactId.text
        if len(library_array) == 0 or library in library_array:
            script = os.path.join(".", "eng", "common", "scripts", "Update-ChangeLog.ps1")
            commands = [
                "pwsh",
                script,
                "--Version",
                version,
                "--ChangeLogPath",
                changelog,
                "--Unreleased:$true", # If is_increment is false then a release is being prepped
                "--ReplaceLatestEntryTitle:$" + str(not is_increment) # If this call is not a result of auto version increment then replace the latest entry with the current version
            ]
            # Run script to update change log
            run_check_call(commands, '.')
    else:
        print('There is no CHANGELOG.md file in {}, skipping update'.format(dirname))
def update_changelog(pom_file, is_unreleased, replace_version):

    # Before doing anything, ensure that there is a changelog.md file sitting next to the pom file
    dirname = os.path.dirname(pom_file)
    changelog = os.path.join(dirname, "CHANGELOG.md")

    if os.path.isfile(changelog):
        tree = ET.parse(pom_file)
        xml_root = tree.getroot()
        xml_version = xml_root.find(
            '{http://maven.apache.org/POM/4.0.0}version')
        version = xml_version.text

        script = os.path.join(".", "eng", "common", "Update-Change-Log.ps1")
        commands = [
            "pwsh",
            script,
            "--Version",
            version,
            "--ChangeLogPath",
            changelog,
            "--Unreleased",
            str(
                is_unreleased
            ),  # if this call is being made as the result of the auto version increment then it'll be unreleased
            "--ReplaceVersion",
            str(replace_version)
        ]
        # Run script to update change log
        run_check_call(commands, '.')
    else:
        print('There is no CHANGELOG.md file in {}, skipping update'.format(
            dirname))