Beispiel #1
0
def main():
    assert_git_config()

    try:
        usage = ("""usage: %prog <command> [options]
       %prog clone [-r alias] [-m URL]
       %prog branch [-r alias] [-m URL] [--rf package] [--dryrun]
       %prog prepare [-r alias] [-m URL] [--rf package] [--dryrun]
       %prog perform [-r alias] [-m URL] [--rf package] [--dryrun]""")
        description = """Release Nuxeo Packages.\n
The first call must provide an URL for the configuration. If set to '' (empty string), it defaults to '%s'. You can use
a local file URL ('file://').\n
Then, a 'release.ini' file is generated and will be reused for the next calls. For each package, a
'release-$PACKAGE_NAME.log' file is also generated and corresponds to the file generated by the release.py script.\n
The 'release.ini' file contains informations about the release process:\n
- 'prepared = True' if the prepare task succeeded,\n
- 'performed = True' if the perform task succeeded,\n
- 'uploaded = ...' if an upload successfully happened,\n
- 'skip = Failed!' followed by a stack trace in case of error.\n
The script can be re-called: it will skip the packages with a skip value and skip the prepare (or perform) if
'prepared = True' (or 'performed = True').\n
Failed uploads are not retried and must be manually done.""" % DEFAULT_MP_CONF_URL
        help_formatter = IndentedHelpFormatterWithNL(max_help_position=7, width=get_terminal_size()[0])
        parser = optparse.OptionParser(usage=usage, description=description, formatter=help_formatter)
        parser.add_option('-r', action="store", type="string", dest='remote_alias', default='origin',
                          help="""The Git alias of remote URL. Default: '%default'""")
        parser.add_option('-m', "--marketplace-conf", action="store", type="string", dest='marketplace_conf',
                          default=None, help="""The Marketplace configuration URL. Default: '%default'""")
        parser.add_option('-i', '--interactive', action="store_true", dest='interactive', default=False,
                          help="""Not implemented (TODO NXP-8573). Interactive mode. Default: '%default'""")
        parser.add_option('--rf', '--restart-from', action="store", dest='restart_from', default=None,
                          help="""Restart from a package. Default: '%default'""")
        parser.add_option('--dryrun', action="store_true", dest='dryrun', default=False,
                          help="""Dry run mode. Default: '%default'""")
        (options, args) = parser.parse_args()
        if len(args) == 1:
            command = args[0]
        elif len(args) > 1:
            raise ExitException(1, "'command' must be a single argument. See usage with '-h'.")
        full_release = ReleaseMP(options.remote_alias, options.restart_from, options.marketplace_conf)
        if "command" not in locals():
            raise ExitException(1, "Missing command. See usage with '-h'.")
        elif command == "clone":
            full_release.clone()
        elif command == "branch":
            full_release.release_branch(dryrun=options.dryrun)
        elif command == "prepare":
            full_release.prepare(dryrun=options.dryrun)
        elif command == "perform":
            full_release.perform(dryrun=options.dryrun)
        elif command == "test":
            full_release.test()
        else:
            raise ExitException(1, "Unknown command! See usage with '-h'.")
    except ExitException, e:
        if e.message is not None:
            log("[ERROR] %s" % e.message, sys.stderr)
        sys.exit(e.return_code)
Beispiel #2
0
def main():
    assert_git_config()

    try:
        usage = ("""usage: %prog <command> [options]
       %prog clone [-r alias] [-m URL]
       %prog branch [-r alias] [-m URL] [--rf package] [--dryrun]
       %prog prepare [-r alias] [-m URL] [--rf package] [--dryrun]
       %prog perform [-r alias] [-m URL] [--rf package] [--dryrun]""")
        description = """Release Nuxeo Packages.\n
The first call must provide an URL for the configuration. If set to '' (empty string), it defaults to '%s'. You can use
a local file URL ('file://').\n
Then, a 'release.ini' file is generated and will be reused for the next calls. For each package, a
'release-$PACKAGE_NAME.log' file is also generated and corresponds to the file generated by the release.py script.\n
The 'release.ini' file contains informations about the release process:\n
- 'prepared = True' if the prepare task succeeded,\n
- 'performed = True' if the perform task succeeded,\n
- 'uploaded = ...' if an upload successfully happened,\n
- 'skip = Failed!' followed by a stack trace in case of error.\n
The script can be re-called: it will skip the packages with a skip value and skip the prepare (or perform) if
'prepared = True' (or 'performed = True').\n
Failed uploads are not retried and must be manually done.""" % DEFAULT_MP_CONF_URL
        help_formatter = IndentedHelpFormatterWithNL(max_help_position=7, width=get_terminal_size()[0])
        parser = optparse.OptionParser(usage=usage, description=description, formatter=help_formatter)
        parser.add_option('-r', action="store", type="string", dest='remote_alias', default='origin',
                          help="""The Git alias of remote URL. Default: '%default'""")
        parser.add_option('-m', "--marketplace-conf", action="store", type="string", dest='marketplace_conf',
                          default=None, help="""The Marketplace configuration URL. Default: '%default'""")
        parser.add_option('-i', '--interactive', action="store_true", dest='interactive', default=False,
                          help="""Not implemented (TODO NXP-8573). Interactive mode. Default: '%default'""")
        parser.add_option('--rf', '--restart-from', action="store", dest='restart_from', default=None,
                          help="""Restart from a package. Default: '%default'""")
        parser.add_option('--dryrun', action="store_true", dest='dryrun', default=False,
                          help="""Dry run mode. Default: '%default'""")
        (options, args) = parser.parse_args()
        if len(args) == 1:
            command = args[0]
        elif len(args) > 1:
            raise ExitException(1, "'command' must be a single argument. See usage with '-h'.")
        full_release = ReleaseMP(options.remote_alias, options.restart_from, options.marketplace_conf)
        if "command" not in locals():
            raise ExitException(1, "Missing command. See usage with '-h'.")
        elif command == "clone":
            full_release.clone()
        elif command == "branch":
            full_release.release_branch(dryrun=options.dryrun)
        elif command == "prepare":
            full_release.prepare(dryrun=options.dryrun)
        elif command == "perform":
            full_release.perform(dryrun=options.dryrun)
        elif command == "test":
            full_release.test()
        else:
            raise ExitException(1, "Unknown command! See usage with '-h'.")
    except ExitException, e:
        if e.message is not None:
            log("[ERROR] %s" % e.message, sys.stderr)
        sys.exit(e.return_code)
def main():
    assert_git_config()

    try:
        usage = ("""usage: %prog <command> [options]
       %prog clone [-r alias] [-m URL] [-d PATH]
       %prog branch [-r alias] [-m URL] [-d PATH] [--rf package] [--dryrun]
       %prog prepare [-r alias] [-m URL] [-d PATH] [--rf package] [--dryrun]
       %prog perform [-r alias] [-m URL] [-d PATH] [--rf package] [--dryrun]
\nCommands:
       clone: Clone or update Nuxeo Package repositories.
       branch: Create the release branch so that the branch to release is freed for ongoing development. Following \
'prepare' or 'perform' commands must use option '--next=done'. If kept, that branch will become the maintenance \
branch after release.
       prepare: Prepare the release (build, change versions, tag and package source and distributions). The release \
parameters are stored in release-<package name>.log files generated by the release.py script. \
The first call must provide a Nuxeo Packages configuration URL (option '-m') from which a 'release.ini' file is \
generated and will be reused for the next calls.
       perform: Perform the release (push sources, deploy artifacts and upload packages, tests are always skipped). \
If no parameter is given, they are read from the 'release.ini' file.""")
        description = """Release Nuxeo Packages.\n
You can initiate some parameters with a release log file (option '-d').\n
The 'release.ini' file contains informations about the release process:\n
- 'prepared = True' if the prepare task succeeded,\n
- 'performed = True' if the perform task succeeded,\n
- 'uploaded = ...' if an upload successfully happened,\n
- 'skip = Failed!' followed by a stack trace in case of error.\n
The script can be re-called: it will skip the packages with a skip value and skip the prepare (or perform) if
'prepared = True' (or 'performed = True').\n
Failed uploads are not retried and must be manually done."""
        help_formatter = IndentedHelpFormatterWithNL(
            max_help_position=7, width=get_terminal_size()[0])
        parser = optparse.OptionParser(usage=usage,
                                       description=description,
                                       formatter=help_formatter)
        parser.add_option(
            '-r',
            action="store",
            type="string",
            dest='remote_alias',
            default='origin',
            help="""The Git alias of remote URL. Default: '%default'""")
        parser.add_option(
            '-d',
            "--default",
            action="store",
            type="string",
            dest='default_conf',
            default=None,
            help=
            """The default configuration file (usually '/path/to/release-nuxeo.log').
Default: '%default'""")
        parser.add_option(
            '-m',
            "--marketplace-conf",
            action="store",
            type="string",
            dest='marketplace_conf',
            default=None,
            help=
            """The Nuxeo Packages configuration URL (usually named 'marketplace.ini').
You can use a local file URL ('file://').\n
If set to '' (empty string), then it will default to '""" +
            DEFAULT_MP_CONF_URL + """'. Default: '%default'""")
        parser.add_option(
            '-i',
            '--interactive',
            action="store_true",
            dest='interactive',
            default=False,
            help=
            """Not implemented (TODO NXP-8573). Interactive mode. Default: '%default'"""
        )
        parser.add_option(
            '--rf',
            '--restart-from',
            action="store",
            dest='restart_from',
            default=None,
            help="""Restart from a package. Default: '%default'""")
        parser.add_option('--dryrun',
                          action="store_true",
                          dest='dryrun',
                          default=False,
                          help="""Dry run mode. Default: '%default'""")
        (options, args) = parser.parse_args()
        if len(args) == 1:
            command = args[0]
        elif len(args) > 1:
            raise ExitException(
                1, "'command' must be a single argument. See usage with '-h'.")
        full_release = ReleaseMP(options.remote_alias, options.restart_from,
                                 options.default_conf,
                                 options.marketplace_conf)
        if "command" not in locals():
            raise ExitException(1, "Missing command. See usage with '-h'.")
        elif command == "clone":
            full_release.clone()
        elif command == "branch":
            full_release.release_branch(dryrun=options.dryrun)
        elif command == "prepare":
            full_release.prepare(dryrun=options.dryrun)
        elif command == "perform":
            full_release.perform(dryrun=options.dryrun)
        elif command == "test":
            full_release.test()
        else:
            raise ExitException(1, "Unknown command! See usage with '-h'.")
    except ExitException, e:
        if e.message is not None:
            log("[ERROR] %s" % e.message, sys.stderr)
        sys.exit(e.return_code)
Beispiel #4
0
def main():
    global namespaces
    assert_git_config()
    namespaces = {"pom": "http://maven.apache.org/POM/4.0.0"}
    etree.register_namespace('pom', 'http://maven.apache.org/POM/4.0.0')

    try:
        if not os.path.isdir(".git"):
            raise ExitException(1, "That script must be ran from root of a Git"
                                + " repository")
        usage = ("usage: %prog [options] <command>\n\nCommands:\n"
                 "  prepare: Prepare the release (build, change versions, tag "
                 "and package source and distributions). The release "
                 "parameters are stored in a release.log file.\n"
                 "  perform: Perform the release (push sources, deploy "
                 "artifacts and upload packages). If no parameter is given, "
                 "they are read from the release.log file.\n"
                 "  package: Package distributions and source code in the "
                 "archives directory.")
        parser = optparse.OptionParser(usage=usage,
                                       description="""Release Nuxeo from
a given branch, tag the release, then set the next SNAPSHOT version.  If a
maintenance version was provided, then a maintenance branch is kept, else it is
deleted after release.""")
        parser.add_option('-r', action="store", type="string",
                          dest='remote_alias',
                          default='origin',
                          help="""the Git alias of remote URL
                          (default: %default)""")
        parser.add_option('-f', '--final', action="store_true",
                          dest='is_final', default=False,
                          help='is it a final release? (default: %default)')
        parser.add_option("-b", "--branch", action="store", type="string",
                          help='branch to release (default: current branch)',
                          dest="branch", default="auto")
        parser.add_option("-t", "--tag", action="store", type="string",
                          dest="tag", default="auto",
                          help="""if final option is True, then the default tag
is the current version minus '-SNAPSHOT', else the 'SNAPSHOT' keyword is
replaced with a date (aka 'date-based release')""")
        parser.add_option("-n", "--next", action="store", type="string",
                          dest="next_snapshot", default="auto",
                          help="""next snapshot. If final option is True, then
the next snapshot is the current one increased, else it is equal to the current
""")
        parser.add_option('-m', '--maintenance', action="store",
                          dest='maintenance', default="auto",
                          help="""maintenance version (by default, the
maintenance branch is deleted after release)""")
        parser.add_option('-i', '--interactive', action="store_true",
                          dest='interactive', default=False,
                          help="""Not implemented (TODO NXP-8573). Interactive
mode.""")
        parser.add_option('-d', '--deploy', action="store_true",
                          dest='deploy', default=False,
                          help="""deploy artifacts to nightly repository""")
        parser.add_option('--skipTests', action="store_true",
                          dest='skipTests', default=False,
                          help="""skip tests execution (but compile them)""")
        (options, args) = parser.parse_args()
        if len(args) == 1:
            command = args[0]
        elif len(args) > 1:
            raise ExitException(1, "'command' must be a single argument. "
                                "See usage with '-h'.")

        release_log = os.path.abspath(os.path.join(os.getcwd(), os.pardir,
                                               "release.log"))
        if ("command" in locals() and command == "perform"
            and os.path.isfile(release_log)
            and options == parser.get_default_values()):
            log("Reading parameters from %s ..." % release_log)
            with open(release_log, "rb") as f:
                options.remote_alias = f.readline().split("=")[1].strip()
                options.branch = f.readline().split("=")[1].strip()
                options.tag = f.readline().split("=")[1].strip()
                options.next_snapshot = f.readline().split("=")[1].strip()
                options.maintenance = f.readline().split("=")[1].strip()
                options.is_final = f.readline().split("=")[1].strip() == "True"
                options.skipTests = f.readline().split("=")[1].strip() == "True"

        repo = Repository(os.getcwd(), options.remote_alias)
        if options.branch == "auto":
            options.branch = repo.get_current_version()
        system("git fetch %s" % (options.remote_alias))
        repo.git_update(options.branch)
        release = Release(repo, options.branch, options.tag,
                          options.next_snapshot, options.maintenance,
                          options.is_final, options.skipTests)
        release.log_summary("command" in locals() and command != "perform")
        if "command" not in locals():
            raise ExitException(1, "Missing command. See usage with '-h'.")
        elif command == "prepare":
            release.prepare(options.deploy)
        elif command == "perform":
            release.perform()
        elif command == "package":
            repo.clone()
            # workaround for NXBT-121: use install instead of package
            repo.mvn("clean install", skip_tests=options.skipTests,
                     profiles="qa")
            release.package_all(release.snapshot)
        elif command == "test":
            release.test()
        else:
            raise ExitException(1, "Unknown command! See usage with '-h'.")
    except ExitException, e:
        if e.message is not None:
            log("[ERROR] %s" % e.message, sys.stderr)
        sys.exit(e.return_code)
Beispiel #5
0
def main():
    assert_git_config()

    try:
        usage = ("""usage: %prog <command> [options]
       %prog clone [-r alias] [-m URL] [-d PATH]
       %prog branch [-r alias] [-m URL] [-d PATH] [--rf package] [--dryrun]
       %prog prepare [-r alias] [-m URL] [-d PATH] [--rf package] [--dryrun]
       %prog perform [-r alias] [-m URL] [-d PATH] [-o owner] [--rf package] [--dryrun]
\nCommands:
       clone: Clone or update Nuxeo Package repositories.
       branch: Create the release branch so that the branch to release is freed for ongoing development. Following \
'prepare' or 'perform' commands must use option '--next=done'. If kept, that branch will become the maintenance \
branch after release.
       prepare: Prepare the release (build, change versions, tag and package source and distributions). The release \
parameters are stored in release-<package name>.log files generated by the release.py script. \
The first call must provide a Nuxeo Packages configuration URL (option '-m') from which a 'release.ini' file is \
generated and will be reused for the next calls.
       perform: Perform the release (push sources, deploy artifacts and upload packages, tests are always skipped). \
If no parameter is given, they are read from the 'release.ini' file.""")
        description = """Release Nuxeo Packages.\n
You can initiate some parameters with a release log file (option '-d').\n
The 'release.ini' file contains informations about the release process:\n
- 'prepared = True' if the prepare task succeeded,\n
- 'performed = True' if the perform task succeeded,\n
- 'uploaded = ...' if an upload successfully happened,\n
- 'skip = Failed!' followed by a stack trace in case of error.\n
The script can be re-called: it will skip the packages with a skip value and skip the prepare (or perform) if
'prepared = True' (or 'performed = True').\n
Failed uploads are not retried and must be manually done."""
        help_formatter = IndentedHelpFormatterWithNL(max_help_position=7, width=get_terminal_size()[0])
        parser = optparse.OptionParser(usage=usage, description=description, formatter=help_formatter)
        parser.add_option('-r', action="store", type="string", dest='remote_alias', default='origin',
                          help="""The Git alias of remote URL. Default: '%default'""")
        parser.add_option('-d', "--default", action="store", type="string", dest='default_conf',
                          default=None, help="""The default configuration file (usually '/path/to/release-nuxeo.log').
Default: '%default'""")
        parser.add_option('-m', "--marketplace-conf", action="store", type="string", dest='marketplace_conf',
                          default=None, help="""The Nuxeo Packages configuration URL (usually named 'marketplace.ini').
You can use a local file URL ('file://').\n
If set to '' (empty string), then it will default to '""" + DEFAULT_MP_CONF_URL + """'. Default: '%default'""")
        parser.add_option('-o', "--owner", action="store", type="string", dest='owner',
                          default=None, help="""The Nuxeo Package owner, if the package is private.
This is the id of the connect client document on Connect. Sample value: 45a78af-7f83-44b2-79e1-f102abf7e435.""")
        parser.add_option('-i', '--interactive', action="store_true", dest='interactive', default=False,
                          help="""Not implemented (TODO NXP-8573). Interactive mode. Default: '%default'""")
        parser.add_option('--rf', '--restart-from', action="store", dest='restart_from', default=None,
                          help="""Restart from a package. Default: '%default'""")
        parser.add_option('--dryrun', action="store_true", dest='dryrun', default=False,
                          help="""Dry run mode. Default: '%default'""")
        (options, args) = parser.parse_args()
        if len(args) == 1:
            command = args[0]
        elif len(args) > 1:
            raise ExitException(1, "'command' must be a single argument. See usage with '-h'.")
        full_release = ReleaseMP(options.remote_alias, options.restart_from, options.default_conf,
                                 options.marketplace_conf)
        if "command" not in locals():
            raise ExitException(1, "Missing command. See usage with '-h'.")
        elif command == "clone":
            full_release.clone()
        elif command == "branch":
            full_release.release_branch(dryrun=options.dryrun)
        elif command == "prepare":
            full_release.prepare(dryrun=options.dryrun)
        elif command == "perform":
            full_release.perform(dryrun=options.dryrun)
        elif command == "test":
            full_release.test()
        else:
            raise ExitException(1, "Unknown command! See usage with '-h'.")
    except ExitException, e:
        if e.message is not None:
            log("[ERROR] %s" % e.message, sys.stderr)
        sys.exit(e.return_code)