├── README.md ├── conanfile.py └── Jenkinsfile /README.md: -------------------------------------------------------------------------------- 1 | # conanTools 2 | A conan package containing helper functions for other conanfile.py 3 | -------------------------------------------------------------------------------- /conanfile.py: -------------------------------------------------------------------------------- 1 | from conans import ConanFile, tools 2 | 3 | def git_get_semver(): 4 | """Uses git to work out a semver compliant version tag""" 5 | git = tools.Git() 6 | try: 7 | # If not in a git repo this command will output error to stderr. 8 | # So we redirect the error message to /dev/null 9 | prev_tag = git.run("describe --tags --abbrev=0 2> /dev/null") 10 | commits_behind = int(git.run("rev-list --count %s..HEAD" % (prev_tag))) 11 | # Commented out checksum due to a potential bug when downloading from bintray 12 | #checksum = git.run("rev-parse --short HEAD") 13 | if prev_tag.startswith("v"): 14 | prev_tag = prev_tag[1:] 15 | if commits_behind > 0: 16 | prev_tag_split = prev_tag.split(".") 17 | prev_tag_split[-1] = str(int(prev_tag_split[-1]) + 1) 18 | output = "%s-%d" % (".".join(prev_tag_split), commits_behind) 19 | else: 20 | output = "%s" % (prev_tag) 21 | return output 22 | except: 23 | return '0.0.0' 24 | 25 | class ConanTools(ConanFile): 26 | name = "conan-tools" 27 | version = git_get_semver() 28 | license = "Apache-2.0" 29 | description = "Functions used across multiple conanfile.py in the IncludeOS project" 30 | url = "https://github.com/includeos/conanTools" 31 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { label 'ubuntu-18.04' } 3 | options { checkoutToSubdirectory('src') } 4 | environment { 5 | CONAN_USER_HOME = "${env.WORKSPACE}" 6 | REMOTE = "${env.CONAN_REMOTE}" 7 | PACKAGE = 'conan-tools' 8 | USER = 'includeos' 9 | CHAN_LATEST = 'latest' 10 | CHAN_STABLE = 'stable' 11 | BINTRAY_CREDS = credentials('devops-includeos-user-pass-bintray') 12 | SRC = "${env.WORKSPACE}/src" 13 | } 14 | 15 | stages { 16 | stage('Setup') { 17 | steps { 18 | sh script: "ls -A | grep -v src | xargs rm -r || :", label: "Clean workspace" 19 | sh script: "conan config install https://github.com/includeos/conan_config.git", label: "conan config install" 20 | } 21 | } 22 | stage('Export') { 23 | steps { 24 | sh script: "conan export $SRC $USER/$CHAN_LATEST", label: "Export conan package" 25 | script { VERSION = sh(script: "conan inspect -a version $SRC | cut -d ' ' -f 2", returnStdout: true).trim() } 26 | } 27 | } 28 | stage('Upload to bintray') { 29 | parallel { 30 | stage('Latest release') { 31 | when { branch 'master' } 32 | steps { 33 | upload_package("$CHAN_LATEST") 34 | } 35 | } 36 | stage('Stable release') { 37 | when { buildingTag() } 38 | steps { 39 | sh script: "conan copy --all $PACKAGE/$VERSION@$USER/$CHAN_LATEST $USER/$CHAN_STABLE", label: "Copy to stable channel" 40 | upload_package("$CHAN_STABLE") 41 | } 42 | } 43 | } 44 | } 45 | } 46 | } 47 | 48 | def upload_package(String channel) { 49 | sh script: """ 50 | conan user -p $BINTRAY_CREDS_PSW -r $REMOTE $BINTRAY_CREDS_USR 51 | conan upload --all -r $REMOTE $PACKAGE/$VERSION@$USER/$channel 52 | """, label: "Upload to bintray" 53 | } 54 | --------------------------------------------------------------------------------