def package(target=None, conf=None): "Builds a package from the current build output." if conf is None: conf = get_conf() archive_path = os.path.join(conf.paths.projectroot, conf.paths.buildarchive) fn = package_filename(archive_path, target, conf) pconf = conf_from_list('target', ingest_yaml_list(os.path.join(conf.paths.projectroot, conf.paths.builddata, 'push.yaml'))) if target is None: pconf = pconf[pconf.keys()[0]] else: pconf = pconf[target] if not os.path.exists(archive_path): os.makedirs(archive_path) puts('[deploy] [tarball]: creating {0} directory'.format(archive_path)) else: if not os.path.isdir(archive_path): abort('[ERROR]: {0} exists and is not a directory.'.format(archive_path)) arc_conf = os.path.join(conf.paths.projectroot, conf.paths.branch_output, 'conf.json') with open(arc_conf, 'w') as f: json.dump(get_build_metadata(conf), f, indent=2) with tarfile.open(fn, 'w:gz') as t: if 'branched' in pconf.options: input_path = os.path.join(conf.paths.projectroot, conf.paths.output, pconf.paths.local, conf.git.branches.current) output_path_name = conf.git.branches.current else: input_path = os.path.join(conf.paths.projectroot, conf.paths.output, pconf.paths.local) output_path_name = os.path.split(pconf.paths.local)[-1] t.add(name=input_path, arcname=output_path_name) t.add(arc_conf, arcname='conf.json') if 'static' in pconf.paths: for path in pconf.paths.static: rendered_path = os.path.join(conf.paths.projectroot, conf.paths.public, path) if os.path.exists(rendered_path): t.add(name=rendered_path, arcname=path) puts('[deploy] [tarball]: created {0} as archive of current build artifacts.'.format(fn))
def package(target=None, conf=None): "Builds a package from the current build output." if conf is None: conf = get_conf() archive_path = os.path.join(conf.paths.projectroot, conf.paths.buildarchive) fn = package_filename(archive_path, target, conf) pconf = conf_from_list( "target", ingest_yaml_list(os.path.join(conf.paths.projectroot, conf.paths.builddata, "push.yaml")) ) if target is None: pconf = pconf[pconf.keys()[0]] else: pconf = pconf[target] if not os.path.exists(archive_path): os.makedirs(archive_path) puts("[deploy] [tarball]: creating {0} directory".format(archive_path)) else: if not os.path.isdir(archive_path): abort("[ERROR]: {0} exists and is not a directory.".format(archive_path)) arc_conf = os.path.join(conf.paths.projectroot, conf.paths.branch_output, "conf.json") with open(arc_conf, "w") as f: json.dump(get_build_metadata(conf), f, indent=2) with tarfile.open(fn, "w:gz") as t: if "branched" in pconf.options: input_path = os.path.join( conf.paths.projectroot, conf.paths.output, pconf.paths.local, conf.git.branches.current ) output_path_name = conf.git.branches.current else: input_path = os.path.join(conf.paths.projectroot, conf.paths.output, pconf.paths.local) output_path_name = os.path.split(pconf.paths.local)[-1] t.add(name=input_path, arcname=output_path_name) t.add(arc_conf, arcname="conf.json") if "static" in pconf.paths: for path in pconf.paths.static: rendered_path = os.path.join(conf.paths.projectroot, conf.paths.public, path) if os.path.exists(rendered_path): t.add(name=rendered_path, arcname=path) puts("[deploy] [tarball]: created {0} as archive of current build artifacts.".format(fn))
def deploy(target, conf=None, pconf=None): """Deploys a site. Specifies the deployment target defined in 'push.yaml'""" conf = lazy_conf(conf) push_conf = ingest_yaml_list(os.path.join(conf.paths.projectroot, conf.paths.builddata, 'push.yaml')) pconf = conf_from_list('target', push_conf)[target] if pconf['target'] != target: abort('[deploy] [ERROR]: this build environment does not support the {0} target'.format(target)) res = runner(deploy_jobs(target, conf, pconf), pool=2) puts('[deploy]: pushed {0} targets'.format(len(res)))