-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
128 lines (110 loc) · 3.86 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Conan Dependency Submission
description: Submits Conan dependencies to the GitHub Dependency Submission API
branding:
icon: "square"
color: "blue"
inputs:
target:
description: "The target directory to submit dependencies for"
required: false
python-version:
description: "The version of python to use"
required: false
default: "3.10"
choices: ["3.12", "3.11", "3.10", "3.9", "3.8", "3.7"]
conan-version:
description: "The version of conan to use"
required: false
default: "2.0.8"
github-server:
description: "The GitHub server to use"
required: false
default: "github.com"
conanfile:
description: "The conanfile to use"
required: false
conan-profile:
description: "Name of the Conan profile to use"
required: false
conan-config:
description: "Location of the Conan configuration to use (from git, http or a folder)"
required: false
runs:
using: "composite"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
- name: Setup SHA (PR)
if: ${{ github.event_name == 'pull_request' }}
env:
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
shell: bash
run: |
echo "LAST_COMMIT_SHA=${PR_HEAD_SHA}" >> ${GITHUB_ENV}
- name: Run Conan
shell: bash
env:
INPUTS_TARGET: ${{ inputs.target }}
INPUTS_PYTHON_VERSION: ${{ inputs.python-version }}
INPUTS_CONAN_VERSION: ${{ inputs.conan-version }}
INPUTS_GITHUB_SERVER: ${{ inputs.github-server }}
INPUTS_CONANFILE: ${{ inputs.conanfile }}
INPUTS_CONAN_PROFILE: ${{ inputs.conan-profile }}
INPUTS_CONAN_CONFIG: ${{ inputs.conan-config }}
GH_TOKEN: ${{ github.token }}
run: |
CONAN_FLAGS=""
# set debug output
if [[ "${RUNNER_DEBUG}" == "1" ]]; then
CONAN_FLAGS+=" --debug"
fi
# set target directory, if given
if [[ -n "${INPUTS_TARGET}" ]]; then
CONAN_FLAGS+=" --target ${INPUTS_TARGET}"
fi
# set conan version
if [[ "${INPUTS_CONAN_VERSION}" == "latest" ]]; then
CONAN_VERSION=""
else
CONAN_VERSION="==${INPUTS_CONAN_VERSION}"
fi
# set conanfile location, if given
if [[ -n "${INPUTS_CONANFILE}" ]]; then
CONAN_FLAGS+=" --conanfile ${INPUTS_CONANFILE}"
fi
# set commit SHA, if given
if [[ -n "${LAST_COMMIT_SHA}" ]]; then
CONAN_FLAGS+=" --sha ${LAST_COMMIT_SHA}"
fi
# set python command
if [[ "${OSTYPE}" == "msys" ]]; then
PYTHON_CMD=python
else
PYTHON_CMD="python${INPUTS_PYTHON_VERSION}"
fi
# upgrade pip
"${PYTHON_CMD}" -m pip -q install --upgrade pip
# install conan
"${PYTHON_CMD}" -m pip -q install conan"${CONAN_VERSION}"
# install Conan configuration, if given
if [[ -n "${INPUTS_CONAN_CONFIG}" ]]; then
conan config install "${INPUTS_CONAN_CONFIG}"
fi
# set conan-profile name, if given, or use/set default
if [[ -n "${INPUTS_CONAN_PROFILE}" ]]; then
CONAN_FLAGS+=" --conan-profile ${INPUTS_CONAN_PROFILE}"
else
if ! conan profile path default >/dev/null 2>&1 ; then
echo "::debug::No default Conan profile found, creating one"
CONAN_PROFILE_OUTPUT=$(conan profile detect 2>&1)
echo "::debug::${CONAN_PROFILE_OUTPUT}"
fi
fi
# install script dependencies
"${PYTHON_CMD}" -m pip install -q -r "${GITHUB_ACTION_PATH}/requirements.txt"
# run conan submission
"${GITHUB_ACTION_PATH}"/conan_submit.py --github-server "${INPUTS_GITHUB_SERVER}" ${CONAN_FLAGS} "${GITHUB_WORKSPACE}"