build.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 import os
5 import re
6 from cpt.packager import ConanMultiPackager
7 from cpt.ci_manager import CIManager
8 from cpt.printer import Printer
9 
10 
11 class BuilderSettings(object):
12 
13  @property
14  def branch(self):
15  """ Get branch name
16  """
17  printer = Printer(None)
18  ci_manager = CIManager(printer)
19  return ci_manager.get_branch()
20 
21  @property
22  def username(self):
23  """ Set BehaviorTree as package's owner
24  """
25  return os.getenv("CONAN_USERNAME", "BehaviorTree")
26 
27  @property
28  def upload(self):
29  """ Set BehaviorTree repository to be used on upload.
30  The upload server address could be customized by env var
31  CONAN_UPLOAD. If not defined, the method will check the branch name.
32  Only master or CONAN_STABLE_BRANCH_PATTERN will be accepted.
33  The master branch will be pushed to testing channel, because it does
34  not match the stable pattern. Otherwise it will upload to stable
35  channel.
36  """
37  if os.getenv("CONAN_UPLOAD", None) is not None:
38  return os.getenv("CONAN_UPLOAD")
39 
40  prog = re.compile(self.stable_branch_pattern)
41  if self.branch and prog.match(self.branch):
42  return "https://api.bintray.com/conan/BehaviorTree/conan"
43 
44  return None
45 
46  @property
48  """ Force to upload when match stable pattern branch
49  """
50  return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True)
51 
52  @property
54  """ Only upload the package the branch name is like a tag
55  """
56  return os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"\d+\.\d+\.\d+")
57 
58  @property
59  def version(self):
60  return self.branch if re.match(self.stable_branch_pattern, self.branch) else "latest"
61 
62  @property
63  def reference(self):
64  """ Read project version from branch name to create Conan referece
65  """
66  return os.getenv("CONAN_REFERENCE", "BehaviorTree.CPP/{}".format(self.version))
67 
68 if __name__ == "__main__":
69  settings = BuilderSettings()
70  builder = ConanMultiPackager(
71  reference=settings.reference,
72  username=settings.username,
73  upload=settings.upload,
74  upload_only_when_stable=settings.upload_only_when_stable,
75  stable_branch_pattern=settings.stable_branch_pattern,
76  test_folder=os.path.join("conan", "test_package"))
77  builder.add_common_builds(pure_c=False)
78  builder.run()
def version(self)
Definition: build.py:59
def stable_branch_pattern(self)
Definition: build.py:53
def reference(self)
Definition: build.py:63
def username(self)
Definition: build.py:22
def branch(self)
Definition: build.py:14
def upload_only_when_stable(self)
Definition: build.py:47
def upload(self)
Definition: build.py:28


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sun Feb 3 2019 03:14:32