Skip to content

Issue #454: Centralize all Config usage to one place. #319

Issue #454: Centralize all Config usage to one place.

Issue #454: Centralize all Config usage to one place. #319

Workflow file for this run

# much of this inspired from: https://cristianadam.eu/20191222/using-github-actions-with-c-plus-plus-and-cmake/
# and also the excellent series from:
# https://www.edwardthomson.com/blog/github_actions_advent_calendar.html
name: CI action for CalChart
on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu Latest GCC",
artifact: "CalChart.tar.xz",
artifact_name: "CalChart-Linux",
os: ubuntu-latest,
}
- {
name: "macOS 13 Clang",
artifact: "CalChart-*.dmg",
artifact_name: "CalChart-macOS",
os: macos-13,
}
- {
name: "Windows Latest MSVC",
artifact: "CalChart-*.exe",
artifact_name: "CalChart-Windows",
os: windows-latest,
}
steps:
- name: checkout
uses: actions/checkout@v3
- name: Checkout unshallow
run: git fetch --unshallow
- name: Checkout submodules
run: git submodule update --init --recursive
- name: Installing Xcode (MacOS)
if: matrix.config.os == 'macos-13'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.0.1'
- name: Installing Dependencies (Windows)
if: matrix.config.os == 'windows-latest'
run: choco install winflexbison
- name: Installing Dependencies (Linux)
if: matrix.config.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install build-essential libgtk-3-dev
- name: Updating to gcc 13 (Linux)
if: matrix.config.os == 'ubuntu-latest'
run: |
sudo apt install gcc-13 g++-13
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 --slave /usr/bin/g++ g++ /usr/bin/g++-13 --slave /usr/bin/gcov gcov /usr/bin/gcov-13
sudo update-alternatives --set gcc /usr/bin/gcc-13
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Run tests
run: ctest --test-dir ${{github.workspace}}/build
- name: Pack (macOS)
if: matrix.config.os == 'macos-latest'
run: pushd ${{github.workspace}}/build && cpack -G DragNDrop
- name: Pack (Windows)
if: matrix.config.os == 'windows-latest'
# it seems that the cmake command provided by chocolatey conflicts with cmake.
# explicitly running cpack from the cmake directory.
run: |
$cmdpath = split-path -parent (get-command cmake).Path
$cpack_cmd = Join-Path -Path $cmdpath -ChildPath cpack
pushd ${{github.workspace}}/build
& $cpack_cmd
- name: Strip (Linux)
if: matrix.config.os == 'ubuntu-latest'
run: cmake --install build --prefix instdir --strip
- name: Pack (Linux)
if: matrix.config.os == 'ubuntu-latest'
working-directory: instdir
run: cmake -E tar cJfv ${{github.workspace}}/build/CalChart.tar.xz .
- name: Upload
uses: actions/upload-artifact@v2
with:
path: ${{github.workspace}}/build/${{ matrix.config.artifact }}
name: ${{ matrix.config.artifact_name }}
release:
if: contains(github.ref, 'tags/v')
name: Release
runs-on: ubuntu-latest
needs: build
steps:
- name: checkout
uses: actions/checkout@v3
- name: Download artifact
uses: actions/download-artifact@v2
with:
path: ./
- name: Display structure of downloaded files
run: ls -R
# using https://github.com/ncipollo/release-action
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: CalChart-*/*
bodyFile: ./LATEST_RELEASE_NOTES.md
draft: true
token: ${{ secrets.GITHUB_TOKEN }}