blob: dfba26428ee60107dc165dbf764202d286d4263e [file] [log] [blame]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
from cpt.packager import ConanMultiPackager
from cpt.ci_manager import CIManager
from cpt.printer import Printer
class BuilderSettings(object):
def username(self):
""" Set catchorg as package's owner
return os.getenv("CONAN_USERNAME", "catchorg")
def login_username(self):
""" Set Bintray login username
return os.getenv("CONAN_LOGIN_USERNAME", "horenmar")
def upload(self):
""" Set Catch2 repository to be used on upload.
The upload server address could be customized by env var
CONAN_UPLOAD. If not defined, the method will check the branch name.
Only master or CONAN_STABLE_BRANCH_PATTERN will be accepted.
The master branch will be pushed to testing channel, because it does
not match the stable pattern. Otherwise it will upload to stable
return os.getenv("CONAN_UPLOAD", "")
def upload_only_when_stable(self):
""" Force to upload when running over tag branch
return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", "True").lower() in ["true", "1", "yes"]
def stable_branch_pattern(self):
""" Only upload the package the branch name is like a tag
return os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+")
def reference(self):
""" Read project version from branch create Conan referece
return os.getenv("CONAN_REFERENCE", "Catch2/{}".format(self._version))
def channel(self):
""" Default Conan package channel when not stable
return os.getenv("CONAN_CHANNEL", "testing")
def _version(self):
""" Get version name from cmake file
pattern = re.compile(r"project\(Catch2 LANGUAGES CXX VERSION (\d+\.\d+\.\d+)\)")
version = "latest"
with open("CMakeLists.txt") as file:
for line in file:
result =
if result:
version =
return version
def _branch(self):
""" Get branch name from CI manager
printer = Printer(None)
ci_manager = CIManager(printer)
return ci_manager.get_branch()
if __name__ == "__main__":
settings = BuilderSettings()
builder = ConanMultiPackager(
test_folder=os.path.join(".conan", "test_package"))