Hello World,
I have a cross platform library that I can build using CMake and toolchains targeting Windows 10, Ubuntu and Debian.
I want to use GitHub action now to automate the process, so I write the following action file:
name: Build
on:
push:
branches: [ main ]jobs:
build:runs-on: ubuntu-latest strategy: matrix: BUILD_TYPE: [Debug, Release] BUILD_TARGET: [DESKTOP_DEBIAN64] BUILD_TARGET_IMAGE: ['xxx/dockerdebianstretch:latest'] #[''] env: BUILD_PACKAGE_NAME: mypackage BUILD_TYPE: ${{matrix.BUILD_TYPE}} BUILD_BIN_DIR: /__w/bofstd/bofstd/build/${{matrix.BUILD_TYPE}} #${{ github.workspace }}/build/${{matrix.BUILD_TYPE}} container: image: ${{matrix.BUILD_TARGET_IMAGE}} steps: - name: First, checkout bofstd source uses: actions/checkout@v2 - rest of the build's instructions
This file is able to build my lib using a docker image containing a debian stretch distribution. Now I want to add 2 more target platforms:
- Ubuntu which is the same than the machine on which I run my file (runs-on: ubuntu-latest)
- Windows
My problems begin here: If I want to build under ubuntu I just need to remove the following lines
container: image: ${{matrix.BUILD_TARGET_IMAGE}}
but this can’t be done with an if in the file. I would like to add a condition on the value of ${{matrix.BUILD_TARGET_IMAGE}} to enable/disable the container: instruction but this is not possible
If I also want to build this lib under windows I need to change
runs-on: ubuntu-latest
in
runs-on: windows-latest
but once again how can I do this in “Github action” workflow.
In short:
My goal is to compile this lib for 3 different operating system using the same Github action file: native ubuntu, native windows and docker debian.
The build process is using cmake so it is the same for the 3 Os. I just want to setup 3 different runtime build environnement to execute my cmake’s build instructions.
Thanks for your time and help