Skip to content

Commit

Permalink
Enable Conan package creation and Artifactory upload on CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanoLusardi committed Aug 5, 2024
1 parent bd3d80f commit ecc34d8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Now it is possible to create and upload a Conan package with the following comma
python scripts/conan/create.py <Debug|Release|RelWithDebInfo> <COMPILER_NAME> <COMPILER_VERSION>

# Upload the package to Artifactory on the teicare remote
python scripts/conan/upload.py teiacare teiacare_video_io/<PACKAGE_VERSION>@
python scripts/conan/upload.py teiacare teiacare_video_io
```


Expand Down
26 changes: 12 additions & 14 deletions ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,15 @@ jobs:
env:
CONAN_USER_HOME: $(Build.SourcesDirectory)
# This step is disabled because we need to align all the settings in the conanfile.py (used to build our package) with the conanfile.txt that we use to consume FFmpeg.

# - script: |
# $(ACTIVATE_VIRTUAL_ENV)
# $(SETUP_BUILD_ENV)
# conan config set general.revisions_enabled=0
# conan remote add teiacare $(artifactory.url)/teiacare
# conan user $(artifactory.username) -p $(artifactory.password) -r teiacare
# python3 scripts/conan/create.py ${{BUILD_TYPE}} $(COMPILER) $(COMPILER_VERSION)
# python3 scripts/conan/upload.py teiacare teiacare_video_io/0.1.0@
# displayName: 'Create Conan Package'
# timeoutInMinutes: 5
# env:
# CONAN_USER_HOME: $(Build.SourcesDirectory)
- script: |
$(ACTIVATE_VIRTUAL_ENV)
$(SETUP_BUILD_ENV)
conan config set general.revisions_enabled=0
conan remote add teiacare $(artifactory.url)/teiacare
conan user $(artifactory.username) -p $(artifactory.password) -r teiacare
python3 scripts/conan/create.py ${{BUILD_TYPE}} $(COMPILER) $(COMPILER_VERSION)
python3 scripts/conan/upload.py teiacare teiacare_video_io
displayName: 'Create Conan Package'
timeoutInMinutes: 5
env:
CONAN_USER_HOME: $(Build.SourcesDirectory)
3 changes: 2 additions & 1 deletion scripts/conan/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def conan_create(conanfile_directory, profile_path, build_type):
'--settings', f'build_type={build_type}',
'--profile:build', f'{profile_path}',
'--profile:host', f'{profile_path}',
'--build', 'missing'
'--build', 'missing',
'--test-folder', 'None' # TODO: remove this line once test_package is working properly
]
run(command)

Expand Down
15 changes: 14 additions & 1 deletion scripts/conan/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
import pathlib
import sys
import os
import re

def get_project_version():
with open('VERSION', encoding='utf8') as version_file:
version_regex = r'^\d+\.\d+\.\d+$'
version = version_file.read().strip()
if re.match(version_regex, version):
return version
else:
raise ValueError(f"Invalid version detected into file VERSION: {version}")

def setup_conan_home():
current_working_directory = pathlib.Path().resolve()
Expand All @@ -39,14 +49,17 @@ def run(command):
print(f'Unhandled Exception: {e}')

def conan_create(remote_name, package_name, force):
package_version = get_project_version()
print(f'{package_name}/{package_version}')

command = [
'conan',
'upload',
'--all',
'--confirm',
'--parallel',
'--remote', remote_name,
package_name
f'{package_name}/{package_version}@'
]

if force:
Expand Down

0 comments on commit ecc34d8

Please sign in to comment.