Exemple #1
0
 def upload_file(self, url, mp_file, dryrun=False, owner=None):
     """ Upload the given mp_file on the given Connect URL."""
     cmd = "curl -i -n -F package=@%s %s%s" % (
         mp_file, url, "/site/marketplace/upload?batch=true")
     if owner:
         cmd += "&owner=%s" % (owner, )
     return system(cmd, failonerror=False, run=(not dryrun))
Exemple #2
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)
Exemple #3
0
 def upload(self, url, mp_file, dryrun=False):
     """ Upload the given mp_file on the given Connect URL."""
     cmd = ("curl -i -n -F package=@%s %s%s" %
            (mp_file, url, "/site/marketplace/upload?batch=true"))
     system(cmd, run=(not dryrun))
Exemple #4
0
 def upload_file(self, url, mp_file, dryrun=False):
     """ Upload the given mp_file on the given Connect URL."""
     cmd = "curl -i -n -F package=@%s %s%s" % (mp_file, url, "/site/marketplace/upload?batch=true")
     return system(cmd, failonerror=False, run=(not dryrun))
Exemple #5
0
 def upload(self, url, mp_file):
     """ Upload the given mp_file on the given Connect URL."""
     cmd = ("curl -i -n -F package=@%s %s%s"
            % (mp_file, url, "/site/marketplace/upload?batch=true"))
     system(cmd)