-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
56 lines (53 loc) · 2.63 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
name: 'CMake'
description: 'Use CMake for cross-platform build, install and test automation.'
inputs:
# The default clone path of actions/checkout equals $GITHUB_WORKSPACE (or ${{ github.workspace }}).
cmake-source-dir:
description: 'Path to the root directory of the CMake project to build.'
default: ${{ github.workspace }}
cmake-build-dir:
description: 'Path to the directory which CMake will use as the root of the build directory.'
default: ${{ github.workspace }}/build
cmake-install-dir:
description: 'Path to the directory which CMake will use as the root of the install directory. Overrides the installation prefix, CMAKE_INSTALL_PREFIX.'
default: ${{ github.workspace }}/install
cmake-build-type:
description: 'CMake build type. E.g.: Release.'
default: 'Release'
cmake-configure-flags:
description: 'CMake configure flags that can be set as -D<key>=<value>, etc.'
default: ''
cmake-install:
description: 'Installs the build when set to true.'
default: false
cmake-ctest:
description: 'Tests the build using CTest when set to true.'
default: false
runs:
using: "composite"
steps:
- name: Configure
shell: bash
# Visual Studio ignores -DCMAKE_BUILD_TYPE=$BUILD_TYPE and will use cmake --config $BUILD_TYPE.
# Make like generators will do the opposite.
run: cmake -S $(echo "${{ inputs.cmake-source-dir }}" | awk '{gsub(/\\/,"/", $0); print}') -B $(echo "${{ inputs.cmake-build-dir }}" | awk '{gsub(/\\/,"/", $0); print}') -DCMAKE_BUILD_TYPE=${{ inputs.cmake-build-type }} ${{ inputs.cmake-configure-flags }}
- name: Build
shell: bash
run: cmake --build $(echo "${{ inputs.cmake-build-dir }}" | awk '{gsub(/\\/,"/", $0); print}') --config ${{ inputs.cmake-build-type }} -j 3
- name: Install
shell: bash
# Composite actions don't seem to support an if: ${{ <expression> }}, hence the bash based if.
run: |
if [[ $(echo "${{ inputs.cmake-install }}" | awk '{print tolower($0)}') = "true" ]]; then
cmake --install $(echo "${{ inputs.cmake-build-dir }}" | awk '{gsub(/\\/,"/", $0); print}') --prefix $(echo "${{ inputs.cmake-install-dir }}" | awk '{gsub(/\\/,"/", $0); print}') --config ${{ inputs.cmake-build-type }}
else
echo "Install skipped."
fi
- name: CTest
shell: bash
run: |
if [[ $(echo "${{ inputs.cmake-ctest }}" | awk '{print tolower($0)}') = "true" ]]; then
ctest --test-dir $(echo "${{ inputs.cmake-build-dir }}" | awk '{gsub(/\\/,"/", $0); print}') -C ${{ inputs.cmake-build-type }} -j 3
else
echo "CTest skipped."
fi