forked from mirror/conan-config
Browse Source
The generators will create GitHub Actions scripts which will set the environment for the next steps. Usage as follows in the commandline: ```yml - name: Conan install run: conan install . -g GitHubActionsVirtualRunEnv - name: Activate env run: <conan_generator_dir>/activate_github_actions_runenv.sh - name: run: echo $PATH ``` Contributes to CURA-9177_Fix_CI_CDfix_tk_recipe_env_info
2 changed files with 54 additions and 0 deletions
@ -0,0 +1,27 @@
|
||||
from pathlib import Path |
||||
|
||||
from jinja2 import Template |
||||
|
||||
from conan.tools.env import VirtualBuildEnv |
||||
from conans.model import Generator |
||||
|
||||
|
||||
class GitHubActionsBuildEnv(Generator): |
||||
|
||||
@property |
||||
def filename(self): |
||||
filepath = str(Path(self.conanfile.generators_folder).joinpath("activate_github_actions_buildenv")) |
||||
if self.conanfile.settings.get_safe("os") == "Windows": |
||||
if self.conanfile.conf.get("tools.env.virtualenv:powershell", check_type = bool): |
||||
filepath += ".ps1" |
||||
else: |
||||
filepath += ".bat" |
||||
else: |
||||
filepath += ".sh" |
||||
return filepath |
||||
|
||||
@property |
||||
def content(self): |
||||
template = Template("""{% for k, v in envvars.items() %}echo "{{ k }}={{ v }}" >> $GITHUB_ENV\n{% endfor %}""") |
||||
envvars = self.conanfile.buildenv_info.vars(self.conanfile) |
||||
return template.render(envvars = envvars) |
||||
@ -0,0 +1,27 @@
|
||||
from pathlib import Path |
||||
|
||||
from jinja2 import Template |
||||
|
||||
from conan.tools.env import VirtualRunEnv |
||||
from conans.model import Generator |
||||
|
||||
|
||||
class GitHubActionsRunEnv(Generator): |
||||
|
||||
@property |
||||
def filename(self): |
||||
filepath = str(Path(self.conanfile.generators_folder).joinpath("activate_github_actions_runenv")) |
||||
if self.conanfile.settings.get_safe("os") == "Windows": |
||||
if self.conanfile.conf.get("tools.env.virtualenv:powershell", check_type = bool): |
||||
filepath += ".ps1" |
||||
else: |
||||
filepath += ".bat" |
||||
else: |
||||
filepath += ".sh" |
||||
return filepath |
||||
|
||||
@property |
||||
def content(self): |
||||
template = Template("""{% for k, v in envvars.items() %}echo "{{ k }}={{ v }}" >> $GITHUB_ENV\n{% endfor %}""") |
||||
envvars = self.conanfile.runenv_info.vars(self.conanfile, scope = "run") |
||||
return template.render(envvars = envvars) |
||||
Loading…
Reference in new issue