forked from conan-io/setup-conan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
136 lines (124 loc) · 4.13 KB
/
action.yml
File metadata and controls
136 lines (124 loc) · 4.13 KB
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
129
130
131
132
133
134
135
136
name: 'Setup Conan Client'
description: 'A GitHub Action to install and configure the Conan client'
author: 'Conan.io <conan@jfrog.com>'
inputs:
version:
description: 'Version of Conan 2.x to install'
required: false
default: ''
config_urls:
description: 'URLs or paths to a Conan configuration repository to be installed. Use new lines to separate multiple URLs.'
required: false
default: ''
audit_token:
description: 'Conan audit token to be used for authentication'
required: false
default: ''
home:
description: 'Custom path for Conan cache directory'
required: false
default: ''
cache_packages:
description: 'Cache all Conan packages from the cache'
required: false
default: 'false'
python_version:
description: 'Python version to install'
required: false
default: '3.10'
deprecationMessage: 'This input is deprecated and will be removed in future versions. Use the Python version set in the GitHub runner instead or a GitHub Action to set up Python.'
use_venv:
description: 'Install Conan inside an isolated virtual environment'
required: false
default: 'false'
outputs:
conan-version:
description: "Conan version"
value: ${{ steps.install-conan.outputs.conan-version }}
conan-home:
description: "Conan cache directory"
value: ${{ steps.get-conan-home.outputs.conan-home }}
runs:
using: 'composite'
steps:
- name: Check Conan version
shell: bash
id: check-conan-version
run: |
if [ -n "${{ inputs.version }}" ]; then
conan_version="${{ inputs.version }}"
if [[ "$conan_version" == 1.* ]]; then
echo "ERROR: Conan 1.x is not supported. Please use Conan 2.x"
exit 1
fi
fi
- name: Set CONAN_HOME
if: ${{ inputs.home != '' }}
id: export-conan-home
shell: bash
run: |
echo "CONAN_HOME=${{ inputs.home }}" >> $GITHUB_ENV
- name: Create virtual environment
if: ${{ inputs.use_venv == 'true' }}
shell: bash
run: |
VENV_DIR="${RUNNER_TEMP}/conan-venv"
python -m venv "$VENV_DIR"
if [[ "${{ runner.os }}" == "Windows" ]]; then
BIN_DIR="$VENV_DIR/Scripts"
else
BIN_DIR="$VENV_DIR/bin"
fi
echo "$BIN_DIR" >> "$GITHUB_PATH"
echo "VENV_PIP=$BIN_DIR/pip" >> "$GITHUB_ENV"
echo "VENV_CONAN=$BIN_DIR/conan" >> "$GITHUB_ENV"
echo "VENV_PYTHON=$BIN_DIR/python" >> "$GITHUB_ENV"
- name: 'Install Conan'
shell: bash
id: install-conan
run: |
PYTHON_CMD=${VENV_PYTHON:-python}
$PYTHON_CMD -m pip install --upgrade pip
if [ -n "${{ inputs.version }}" ]; then
$PYTHON_CMD -m pip install conan==${{ inputs.version }}
else
$PYTHON_CMD -m pip install conan
fi
echo "conan-version=$(conan --version | cut -d' ' -f3)" >> $GITHUB_OUTPUT
- name: Detect Conan profile
shell: bash
id: detect-conan-profile
run: |
conan profile detect || true
- name: Get Conan cache folder path
shell: bash
id: get-conan-home
run: echo "conan-home=$(conan config home)" >> $GITHUB_OUTPUT
- name: 'Configure Conan'
if: ${{ inputs.config_urls != '' }}
id: configure-conan
shell: bash
run: |
echo "${{ inputs.config_urls }}" | while read -r url; do
if [ ! -z "$url" ]; then
conan config install "$url"
fi
done
- name: 'Authenticate Audit'
if: ${{ inputs.audit_token != '' }}
id: conan-audit-authentication
shell: bash
run: |
conan audit provider auth conancenter --token=${{ inputs.audit_token }}
- name: Cache Conan packages
if: ${{ inputs.cache_packages == 'true' }}
uses: actions/cache@v4.2.3
id: cache-conan-packages
with:
path: ${{ steps.get-conan-home.outputs.conan-home }}/p
key: conan-${{ steps.install-conan.outputs.conan-version }}-${{ runner.os }}
restore-keys: |
conan-${{ steps.install-conan.outputs.conan-version }}-${{ runner.os }}-
branding:
icon: 'package'
color: 'blue'