Ejemplo n.º 1
0
def make_parser():
    def validate_bump_type(arg):
        # Just check if it parses but return original arg because it is used later
        Tools.get_versioning_command_args(arg)
        return arg

    parser = ArgumentParser()
    parser.add_argument(
        '-r',
        '--release-dir',
        dest='release_dir',
        action='store',
        help='a directory which is a clone of chisel-release default is "."',
        default=".")
    parser.add_argument('-m',
                        '--major-version',
                        dest='major_version',
                        action='store',
                        help='major number of release being bumped',
                        required=True)
    parser.add_argument(
        '-bt',
        '--bump-type',
        dest='bump_type',
        action='store',
        type=validate_bump_type,
        required=True,
        help='Why type of release is this? '
        '[major, minor, rc<#>, rc-clear, ds, ds<YYYYMMDD>, ds-clear]')
    Tools.add_standard_cli_arguments(parser)

    return parser
Ejemplo n.º 2
0
def main():
    try:
        opts, args = getopt.getopt(
            sys.argv[1:],
            "lhr:s:e:",
            ["help", "repo=", "start-step=", "stop-step=", "list-only"]
        )
    except getopt.GetoptError as err:
        print(err)
        usage()
        sys.exit(2)

    release_dir = ""
    start_step = -1
    stop_step = 1000
    list_only = False
    counter = StepCounter()

    for option, value in opts:
        if option in ("--repo", "-r"):
            release_dir = value
        elif option in ("--start-step", "-s"):
            start_step = int(value)
        elif option in ("--stop-step", "-e"):
            stop_step = int(value)
        elif option in ("--list-only", "-l"):
            list_only = True
        elif option in ("--help", "-h"):
            usage()
            exit(1)
        else:
            print(f"Unhandled command line option: {option}")
            usage()
            assert False

    if release_dir == "":
        usage()
        exit(1)

    tools = Tools("build_submodules", release_dir)

    if not list_only:
        if release_dir == "":
            print(f"Error: --repo must be specified to run this script")
            usage()
            exit(1)
        else:
            print(f"chisel-release directory is {os.getcwd()}")
    else:
        print(f"These are the steps to be executed for the {tools.task_name} script")

    tools.set_start_step(start_step)
    tools.set_stop_step(stop_step)
    tools.set_list_only(list_only)

    tools.run_make_test(counter.next_step())
def main():
    current_date = datetime.now().strftime("%Y%m%d")

    try:
        parser = ArgumentParser()
        parser.add_argument('-r', '--release-dir', dest='release_dir', action='store',
                            help='a directory which is a clone of chisel-release, default is "."', default=".")
        parser.add_argument('-m', '--major-version', dest='major_version', action='store',
                            help='major number of snapshots being published', required=True)
        parser.add_argument('-d', '--date-range', dest='date_range', action='store',
                            help='set dates to search for PRs, e.g. ">2021-04-01" or "2021-05-31..2021-05-01',
                            default=current_date)
        parser.add_argument('-c', '--clear-db', dest='clear_db', action='store_true',
                            help='clears issues collection from each repo database before downloading', default=False)
        parser.add_argument('-g', '--github-token', dest='github_token', action='store',
                            help='Way to set your github token, will use env var GHRPAT if not set by this',
                            default="")
        Tools.add_standard_cli_arguments(parser)

        args = parser.parse_args()

        release_dir = args.release_dir
        release_dot_x_version = f"{args.major_version}.x"
        release_version = f"{args.major_version}-release"
        if args.github_token == "":
            token = os.getenv("GHRPAT")
            if token is None or token == "":
                print(f"You must either set a GHRPAT environment variable or use '--github-token token'")
                print(parser.usage)
        else:
            token = args.github_token
            os.environ['GHRPAT'] = token
        date_range = args.date_range
        clear_db = args.clear_db
        start_step = args.start_step
        stop_step = args.stop_step
        list_only = args.list_only
        counter = StepCounter()

        print(f"chisel-release directory is {os.getcwd()}")
        print(f"release specified is {release_dot_x_version}")

        if list_only:
            print(f"These are the steps to be executed for the {sys.argv[0]} script")

        tools = Tools("generate_changlog", release_dir)

        tools.set_start_step(start_step)
        tools.set_stop_step(stop_step)
        tools.set_list_only(list_only)

        #
        # pull in the latest '.x' branches and update the top level
        #
        tools.checkout_branch(counter.next_step(), release_dot_x_version)
        tools.git_pull(counter.next_step())
        tools.run_submodule_update_recursive(counter.next_step())
        tools.run_submodule_fetch_from_origin(counter.next_step())

        tools.populate_db_with_request_issues(counter.next_step(), date_range, clear_db)
        tools.verify_version_tag(counter.next_step())
        tools.generate_git_log_one_liners(counter.next_step())
        tools.generate_changelog(counter.next_step())

    except Exception as e:
        print(e)
        sys.exit(2)
Ejemplo n.º 4
0
def main():
    try:
        parser = ArgumentParser()
        parser.add_argument(
            '-r',
            '--release-dir',
            dest='release_dir',
            action='store',
            help=
            'a directory which is a clone of chisel-release default is "."',
            default=".")

        Tools.add_standard_cli_arguments(parser)

        args = parser.parse_args()

        release_dir = args.release_dir
        start_step = args.start_step
        stop_step = args.stop_step
        list_only = args.list_only
        counter = StepCounter()

        tools = Tools("build_submodules", release_dir)

        if not list_only:
            if release_dir == "":
                print(f"Error: --repo must be specified to run this script")
                exit(1)
            else:
                print(f"chisel-release directory is {os.getcwd()}")
        else:
            print(
                f"These are the steps to be executed for the {tools.task_name} script"
            )

        tools.set_start_step(start_step)
        tools.set_stop_step(stop_step)
        tools.set_list_only(list_only)

        tools.run_make_clean_install(counter.next_step())

    except Exception as e:
        print(e)
        sys.exit(2)
def main():
    current_date = datetime.now().strftime("%Y%m%d")

    try:
        parser = ArgumentParser()
        parser.add_argument(
            '-r',
            '--release-dir',
            dest='release_dir',
            action='store',
            help='a directory which is a clone of chisel-release',
            default=".")
        parser.add_argument('-m',
                            '--major-version',
                            dest='major_version',
                            action='store',
                            help='major number of snapshots being published',
                            required=True)
        parser.add_argument('-b',
                            '--start-step',
                            dest='start_step',
                            type=int,
                            action='store',
                            help='command step to start on',
                            default=1)
        parser.add_argument('-e',
                            '--stop-step',
                            dest='stop_step',
                            type=int,
                            action='store',
                            help='command step to end on',
                            default=10000)
        parser.add_argument('-l',
                            '--list-only',
                            dest='list_only',
                            action='store_true',
                            help='list command step, do not execute',
                            default=False)

        args = parser.parse_args()

        release_dir = args.release_dir
        release_dot_x_version = f"{args.major_version}.x"
        start_step = args.start_step
        stop_step = args.stop_step
        list_only = args.list_only
        counter = StepCounter()

        tools = Tools("merge_master_into_dot_x", release_dir)

        if not list_only:
            print(f"chisel-release directory is {os.getcwd()}")
            print(f"release specified is {release_dot_x_version}")
        else:
            print(
                f"These are the steps to be executed for the {tools.task_name} script"
            )

        tools.set_start_step(start_step)
        tools.set_stop_step(stop_step)
        tools.set_list_only(list_only)

        #
        # pull in the latest 'master' branches and update the top level
        #
        tools.checkout_branch(counter.next_step(), "master")
        tools.git_pull(counter.next_step())
        tools.run_submodule_update_recursive(counter.next_step())
        tools.run_make_pull(counter.next_step())
        tools.git_add_dash_u(counter.next_step())
        tools.git_commit(counter.next_step(), "Bump master branches")
        tools.git_push(counter.next_step())

        #
        # pull in the latest '.x' branches and update the top level
        #
        tools.checkout_branch(counter.next_step(), release_dot_x_version)
        tools.git_pull(counter.next_step())
        tools.run_submodule_update_recursive(counter.next_step())
        tools.run_make_pull(counter.next_step())
        tools.git_merge_masters_into_dot_x(counter.next_step())
        tools.git_add_dash_u(counter.next_step())
        tools.git_commit(
            counter.next_step(),
            "Bump .x branches that just had masters merged into them")
        tools.git_push(counter.next_step())

    except Exception as e:
        print(e)
        sys.exit(2)
Ejemplo n.º 6
0
def main():
    try:
        parser = ArgumentParser()
        parser.add_argument(
            '-r',
            '--release-dir',
            dest='release_dir',
            action='store',
            help='a directory which is a clone of chisel-release',
            default=".")
        parser.add_argument('-br',
                            '--branch',
                            dest='branch',
                            action='store',
                            help='branch to build',
                            required=True)

        Tools.add_standard_cli_arguments(parser)

        args = parser.parse_args()

        release_dir = args.release_dir
        start_step = args.start_step
        stop_step = args.stop_step
        list_only = args.list_only
        counter = StepCounter()

        tools = Tools("build_branch", release_dir)

        if not list_only:
            print(f"chisel-release directory is {os.getcwd()}")
        else:
            print(
                f"These are the steps to be executed for the {tools.task_name} script"
            )

        tools.set_start_step(start_step)
        tools.set_stop_step(stop_step)
        tools.set_list_only(list_only)

        tools.checkout_branch(counter.next_step(), "master")

        tools.git_pull(counter.next_step())

        tools.run_submodule_update_recursive(counter.next_step())

        tools.run_make_pull(counter.next_step())

        tools.run_make_install(counter.next_step())

    except Exception as err:
        print(err)
        sys.exit(2)
Ejemplo n.º 7
0
def main():
    try:
        parser = ArgumentParser()
        parser.add_argument(
            '-r',
            '--release-dir',
            dest='release_dir',
            action='store',
            help=
            'a directory which is a clone of chisel-release default is "."',
            default=".")
        parser.add_argument('-bt',
                            '--bump-type',
                            dest='bump_type',
                            action='store',
                            choices=['major', 'minor'],
                            help='Is this a major or a minor release',
                            required=True)
        Tools.add_standard_cli_arguments(parser)

        args = parser.parse_args()

        release_dir = args.release_dir
        bump_type = args.bump_type
        start_step = args.start_step
        stop_step = args.stop_step
        list_only = args.list_only
        counter = StepCounter()

        if release_dir == "":
            print(
                f"Error: both --repo and --release must be specified to run this script"
            )
            parser.print_help()
            exit(1)
        else:
            print(f"chisel-release directory is {os.getcwd()}")

        if not list_only:
            # this will validate bump_tpe and exit on failure
            Tools.get_versioning_command(bump_type)
        else:
            print(
                f"These are the steps to be executed for the {sys.argv[0]} script"
            )

        tools = Tools("set_dated_snapshots", release_dir)

        tools.set_start_step(start_step)
        tools.set_stop_step(stop_step)
        tools.set_list_only(list_only)

        #
        # Change repo's release versions and references
        # according to the 'bumptype'
        #
        tools.bump_release(counter.next_step(), bump_type)
        tools.check_version_updates(counter.next_step())
        tools.publish_signed(counter.next_step())

        tools.comment(
            counter.next_step(), f"""
            You are almost done
                - Follow steps in docs/sonatype_finalize_release.md
                - Then publish/tag_release
                - Then run generate snapshots
            """)
    except Exception as e:
        print(e)
        sys.exit(2)
Ejemplo n.º 8
0
def main():
    try:
        parser = ArgumentParser()
        parser.add_argument(
            '-r',
            '--release-dir',
            dest='release_dir',
            action='store',
            help=
            'a directory which is a clone of chisel-release default is "."',
            default=".")
        parser.add_argument('-rv',
                            '--release-version',
                            dest='release_version',
                            action='store',
                            help='full release number Z.Y.X eg. 3.4.2',
                            required=True)
        parser.add_argument(
            '-d',
            '--dry-run',
            dest='is_dry_run',
            action='store_true',
            help='if set just shows command that will be called')

        Tools.add_standard_cli_arguments(parser)

        args = parser.parse_args()

        release_dir = args.release_dir
        release_version = args.release_version
        start_step = args.start_step
        stop_step = args.stop_step
        list_only = args.list_only
        is_dry_run = args.is_dry_run
        counter = StepCounter()

        if release_dir == "" or args.release_version == "":
            print(
                f"Error: both --repo and --release-version must be specified to run this script"
            )
            usage()
            exit(1)
        else:
            print(f"chisel-release directory is {os.getcwd()}")

        if list_only:
            print(
                f"These are the steps to be executed for the {sys.argv[0]} script"
            )

        tools = Tools("tag_new_release", release_dir)

        cb = tools.get_current_branch(0)
        print(f"current branch {cb}")

        tools.set_start_step(start_step)
        tools.set_stop_step(stop_step)
        tools.set_list_only(list_only)

        tools.tag_submodules(counter.next_step(), is_dry_run)
        tools.tag_top_level(counter.next_step(), is_dry_run, release_version)

        tools.comment(
            counter.next_step(), f"""
            Congratulations your release is published
                - You should probably publish snapshots next
            """)
    except Exception as e:
        print(e)
        sys.exit(2)
Ejemplo n.º 9
0
def main():
    try:
        parser = ArgumentParser()
        parser.add_argument(
            '-r',
            '--release-dir',
            dest='release_dir',
            action='store',
            help='a directory which is a clone of chisel-release',
            default=".")
        parser.add_argument('-br',
                            '--branch',
                            dest='branch',
                            action='store',
                            help='major number of snapshots being published',
                            required=True)

        Tools.add_standard_cli_arguments(parser)

        args = parser.parse_args()

        release_dir = args.release_dir
        branch = args.branch
        start_step = args.start_step
        stop_step = args.stop_step
        list_only = args.list_only
        counter = StepCounter()

        tools = Tools("build_and_test_branch", release_dir)

        if not list_only:
            if release_dir == "" or branch == "":
                print(
                    f"Error: both --repo and --release must be specified to run this script"
                )
                usage()
                exit(1)
            else:
                print(f"chisel-release directory is {os.getcwd()}")
                print(f"release specified is {branch}")
        else:
            print(
                f"These are the steps to be executed for the {tools.task_name} script"
            )

        tools.set_start_step(start_step)
        tools.set_stop_step(stop_step)
        tools.set_list_only(list_only)

        tools.checkout_branch(counter.next_step(), branch)

        tools.git_pull(counter.next_step())

        tools.run_submodule_update_recursive(counter.next_step())

        tools.run_make_pull(counter.next_step())

        tools.run_make_clean_install(counter.next_step())

        tools.run_make_test(counter.next_step())

    except Exception as e:
        print(e)
        sys.exit(2)
Ejemplo n.º 10
0
def main():
    try:
        parser = make_parser()
        args = parser.parse_args()

        release_dir = args.release_dir
        release_dot_x_version = f"{args.major_version}.x"
        release_version = f"{args.major_version}-release"
        bump_type = args.bump_type
        start_step = args.start_step
        stop_step = args.stop_step
        list_only = args.list_only
        counter = StepCounter()

        print(f"chisel-release directory is {os.getcwd()}")
        print(f"release specified is {release_dot_x_version}")

        if list_only:
            print(
                f"These are the steps to be executed for the {sys.argv[0]} script"
            )

        tools = Tools("publish_new_release", release_dir)

        tools.set_start_step(start_step)
        tools.set_stop_step(stop_step)
        tools.set_list_only(list_only)

        #
        # pull in the latest '.x' branches and update the top level
        #
        tools.checkout_branch(counter.next_step(), release_dot_x_version)
        tools.git_pull(counter.next_step())
        tools.run_submodule_update_recursive(counter.next_step())
        tools.run_make_pull(counter.next_step())
        tools.git_add_dash_u(counter.next_step())
        tools.git_commit(counter.next_step(), "Bump .x branches")
        tools.git_push(counter.next_step())

        #
        # pull in the latest '-release' branches and update the top level
        #
        tools.checkout_branch(counter.next_step(), release_version)
        tools.git_pull(counter.next_step())
        tools.run_submodule_update_recursive(counter.next_step())
        tools.run_make_pull(counter.next_step())
        tools.git_add_dash_u(counter.next_step())
        tools.git_commit(counter.next_step(), "Bump -release versions")
        tools.git_push(counter.next_step())

        #
        # Change repo's release versions and references
        # according to the 'bumptype'
        #
        tools.bump_release(counter.next_step(), bump_type)
        tools.check_version_updates(counter.next_step())
        tools.add_and_commit_submodules(counter.next_step())
        tools.git_add_dash_u(counter.next_step())
        tools.git_commit(counter.next_step(), "Bump new -release versions")

        #
        # Merge tracked branches (usually master or .x) in to -release branches
        tools.merge_tracked_branches_into_release_branches(counter.next_step())
        tools.verify_merge(counter.next_step())

        #
        # Test that everything compiles and tests with new release numbers
        #
        tools.run_make_clean(counter.next_step())
        tools.run_make_install(counter.next_step())
        tools.run_make_test(counter.next_step())

        #
        # Commit merges
        #
        tools.commit_each_submodule(counter.next_step())
        tools.git_add_dash_u(counter.next_step())
        tools.git_commit(counter.next_step(),
                         f"Release {release_version} top level committed")

        # Publish release
        #
        tools.publish_signed(counter.next_step())

        #
        # Push release, release numbers have been bumped by here
        #
        tools.push_submodules(counter.next_step())
        tools.git_push(counter.next_step())

        tools.comment(
            counter.next_step(), f"""
            You are almost done
                - Follow steps in docs/sonatype_finalize_release.md
                - Then publish/tag_release
                - Then run generate snapshots
            """)
    except Exception as e:
        print(e)
        sys.exit(2)
Ejemplo n.º 11
0
 def validate_bump_type(arg):
     # Just check if it parses but return original arg because it is used later
     Tools.get_versioning_command_args(arg)
     return arg