build.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 import os
00005 import re
00006 from cpt.packager import ConanMultiPackager
00007 from cpt.ci_manager import CIManager
00008 from cpt.printer import Printer
00009 
00010 
00011 class BuilderSettings(object):
00012 
00013     @property
00014     def branch(self):
00015         """ Get branch name
00016         """
00017         printer = Printer(None)
00018         ci_manager = CIManager(printer)
00019         return ci_manager.get_branch()
00020 
00021     @property
00022     def username(self):
00023         """ Set BehaviorTree as package's owner
00024         """
00025         return os.getenv("CONAN_USERNAME", "BehaviorTree")
00026 
00027     @property
00028     def upload(self):
00029         """ Set BehaviorTree repository to be used on upload.
00030             The upload server address could be customized by env var
00031             CONAN_UPLOAD. If not defined, the method will check the branch name.
00032             Only master or CONAN_STABLE_BRANCH_PATTERN will be accepted.
00033             The master branch will be pushed to testing channel, because it does
00034             not match the stable pattern. Otherwise it will upload to stable
00035             channel.
00036         """
00037         if os.getenv("CONAN_UPLOAD", None) is not None:
00038             return os.getenv("CONAN_UPLOAD")
00039 
00040         prog = re.compile(self.stable_branch_pattern)
00041         if self.branch and prog.match(self.branch):
00042             return "https://api.bintray.com/conan/BehaviorTree/conan"
00043 
00044         return None
00045 
00046     @property
00047     def upload_only_when_stable(self):
00048         """ Force to upload when match stable pattern branch
00049         """
00050         return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True)
00051 
00052     @property
00053     def stable_branch_pattern(self):
00054         """ Only upload the package the branch name is like a tag
00055         """
00056         return os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"\d+\.\d+\.\d+")
00057 
00058     @property
00059     def version(self):
00060         return self.branch if re.match(self.stable_branch_pattern, self.branch) else "latest"
00061 
00062     @property
00063     def reference(self):
00064         """ Read project version from branch name to create Conan referece
00065         """
00066         return os.getenv("CONAN_REFERENCE", "BehaviorTree.CPP/{}".format(self.version))
00067 
00068 if __name__ == "__main__":
00069     settings = BuilderSettings()
00070     builder = ConanMultiPackager(
00071         reference=settings.reference,
00072         username=settings.username,
00073         upload=settings.upload,
00074         upload_only_when_stable=settings.upload_only_when_stable,
00075         stable_branch_pattern=settings.stable_branch_pattern,
00076         test_folder=os.path.join("conan", "test_package"))
00077     builder.add_common_builds(pure_c=False)
00078     builder.run()


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sat Feb 2 2019 03:50:10