blob: 9a857188ccc56cc0828c132f9952bd717de53ffd [file] [log] [blame]
Austin Schuhe89fa2d2019-08-14 20:24:23 -07001#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3import os
4import re
5import subprocess
6from cpt.packager import ConanMultiPackager
7
8
Austin Schuhe89fa2d2019-08-14 20:24:23 -07009
10def get_branch():
11 try:
12 for line in subprocess.check_output("git branch", shell=True).decode().splitlines():
13 line = line.strip()
14 if line.startswith("*") and " (HEAD detached" not in line:
15 return line.replace("*", "", 1).strip()
16 return ""
17 except Exception:
18 pass
19 return ""
20
21
22def get_version():
23 version = get_branch()
24 if os.getenv("TRAVIS", False):
25 version = os.getenv("TRAVIS_BRANCH")
26
27 if os.getenv("APPVEYOR", False):
28 version = os.getenv("APPVEYOR_REPO_BRANCH")
29 if os.getenv("APPVEYOR_REPO_TAG") == "true":
30 version = os.getenv("APPVEYOR_REPO_TAG_NAME")
31
32 match = re.search(r"v(\d+\.\d+\.\d+.*)", version)
33 if match:
34 return match.group(1)
35 return version
36
37
38def get_reference(username):
39 return "flatbuffers/{}@google/stable".format(get_version())
40
41
42if __name__ == "__main__":
43 login_username = os.getenv("CONAN_LOGIN_USERNAME", "aardappel")
44 username = os.getenv("CONAN_USERNAME", "google")
45 upload = os.getenv("CONAN_UPLOAD", "https://api.bintray.com/conan/aardappel/flatbuffers")
46 stable_branch_pattern = os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+.*")
47 test_folder = os.getenv("CPT_TEST_FOLDER", os.path.join("conan", "test_package"))
48 upload_only_when_stable = os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True)
Austin Schuhe89fa2d2019-08-14 20:24:23 -070049
50 builder = ConanMultiPackager(reference=get_reference(username),
51 username=username,
52 login_username=login_username,
53 upload=upload,
54 stable_branch_pattern=stable_branch_pattern,
55 upload_only_when_stable=upload_only_when_stable,
56 test_folder=test_folder)
57 builder.add_common_builds(pure_c=False)
58 builder.run()