Conan: Version Control Issue -- Staging vs. Master branches

Created on 18 Nov 2019  路  5Comments  路  Source: conan-io/conan


First off -- I suspect it is user error on my part, however it isn't obvious what I'm doing incorrectly. I've been reading docs but I'm missing something important here.

My goal is to publish test versions before publishing a master version. When creating my package, I update my local version to something that looks like

MyCompany/0.2.0@myproject/staging

With the eventual goal to get to

MyCompany/1.0.0@myproject/stable

When I upload the 0.2.0/staging build, the recipe looks correct. The source files however don't exist -- just the headers. (possibly issue number 1)

What ends up happening when I try to build a project without MyCompany project in the local caches, it brings it down..... but it is bringing down the master branch from VCS. The Staging branch is what I need.

Somewhere in the mix is not just the package that I thought I was uploading, but the branch of VCS (GitHub in this case), and maybe even a tag. I'm really hoping to not have to create a very complicated script to determine these at upload time on our build machine -- I'm just doing a simple conan upload "*" -r my_package --all

MyCompany, myproject, my_package all substituted for what I'm really using.

Thanks!

question

Most helpful comment

That looks like what I need! I'll give it a go today and see if this works as expected. Thank you for pointing me in the right direction!

All 5 comments

I think I figured out one part, though it doesn't answer the larger question.

If my test app has the following conanfile.txt, this gets the correct branch

[requires]
MyCompany/0.2.0@myproject/staging

[options]
# master is the default. Modify to use a different branch
MyCompany:git_branch=Staging

This works because the conanfile.py has an option def source(self): that allows for different branches.

While I think I understand the relationship now, this doesn't help with an overall packaging structure if the sources that I'm uploading to conan aren't being used. In our case 0.2.0:staging and 0.3.0:staging -- both pull from Staging now and are indistinguishable. Likewise -- if they pulled from master -- 1.0.0:stable and 2.0.0:stable would be indistinguishable if both come from the master branch.

I think what I'm missing is that I need to associate some sort of VCS tag with what I'm uploading to Conan, so that when the recipe is fetched it knows how to fetch the VCS tag from our source control repo.

At the end of the day I want the customer to be able to simply pull the version without having to specify the tag or branch themselves.

Hi @apeterson-branch,

Yes, as you have figured out, Conan does nothing magical with the sources of the package unless you specify so in the recipe (as you did with the option).

However, using an option for this is not the right approach as those will generate different package IDs. IMO the best way to go should be using the SCM feature with the source code of you pacakges next to the recipe https://docs.conan.io/en/latest/creating_packages/package_repo.html#capturing-the-remote-and-commit-scm

That way you will be able to generate packages with different source code from branches master/staging and indicate that in the channel of the package reference.

Please give it a go and let me know if that suits your needs or it is not your use case. Thanks! 馃槃

That looks like what I need! I'll give it a go today and see if this works as expected. Thank you for pointing me in the right direction!

Just to follow-up, this solution worked perfectly! Thanks again for the help!

Glad you find it useful and thanks a lot for reporting 馃槃

Was this page helpful?
0 / 5 - 0 ratings