Better_Software_Header_MobileBetter_Software_Header_Web

Find what you need - explore our website and developer resources

GitHub Actions for C++ and Qt

How to use GitHub Actions for C++ and Qt projects

jobs:
  example_matrix:
    strategy:
      matrix:
        version: [10, 12, 14]
        os: [ubuntu-latest, windows-latest]
- name: Setup VS
  uses: ilammy/msvc-dev-cmd@v1 # action from some kind person on GitHub
- uses: ./.github/actions/setup-rust # action from your own repository
name: CI

on: push # when to trigger this. Here, on every push
jobs:
  build_and_test:
    name: "Build and test"
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest] # we build on GitHub-provided Windows and Linux images
    runs-on: ${{ matrix.os }} # use value from the matrix
    steps:
    - name: Install dependencies (linux)
      run: sudo apt install ninja-build
      if: matrix.os == 'ubuntu-latest' # conditional, runs this step only on the Ubuntu runner
    - name: Install Ninja (windows)    # Ninja is not available in GitHub-provided images,
                                       # see https://github.com/actions/runner-images/issues/514
      run: choco install ninja         # So let's install it through Chocolatey
      if: matrix.os == 'windows-latest'
    - name: Install Qt
      uses: jurplel/install-qt-action@v3
      with:
        version: '6.5.2'
    - uses: ilammy/msvc-dev-cmd@v1 # This action essentially calls vcvarsall.bat for the latest VS in the runner for x64
    - uses: actions/checkout@v3    # Actually check out the sources. GH Actions can run for events that may not require
                                   # sources (e.g. when someone comments on an issue)

    # Here we call CMake manually, there are solutions for that in the Marketplace: https://github.com/marketplace/actions/run-cmake
    - name: Build
      # We don't need to set up the environment variable for CMake to see Qt because the install-qt-action
      # sets up the necessary variables automatically
      run: cmake -S . -B build -G "Ninja Multi-Config" && cmake --build build --config Debug
github_action_run.png

About KDAB


2 Comments

22 - Sept - 2023

Linderman Dominguez

26 - Sept - 2023

Jesper K. Pedersen