-
Notifications
You must be signed in to change notification settings - Fork 3
149 lines (124 loc) · 4.45 KB
/
cmake.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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
# 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
- calchart-3.6
tags:
- '*'
pull_request:
branches:
- main
- calchart-3.6
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-24.04,
}
- {
name: "macOS 14 Clang",
artifact: "CalChart-*.dmg",
artifact_name: "CalChart-macOS",
os: macos-14,
}
- {
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-14'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Installing Dependencies (Windows)
if: matrix.config.os == 'windows-latest'
run: choco install winflexbison
- name: Installing Dependencies (Linux)
if: matrix.config.os == 'ubuntu-24.04'
run: sudo apt-get update && sudo apt-get install build-essential libgtk-3-dev
- name: Updating to gcc 14 (Linux)
if: matrix.config.os == 'ubuntu-24.04'
run: |
sudo apt update
sudo apt install gcc-14 g++-14
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 --slave /usr/bin/g++ g++ /usr/bin/g++-14 --slave /usr/bin/gcov gcov /usr/bin/gcov-14
sudo update-alternatives --set gcc /usr/bin/gcc-14
- 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 --verbose --test-dir ${{github.workspace}}/build
- name: Pack (macOS)
if: matrix.config.os == 'macos-14'
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-24.04'
run: cmake --install build --prefix instdir --strip
- name: Pack (Linux)
if: matrix.config.os == 'ubuntu-24.04'
working-directory: instdir
run: cmake -E tar cJfv ${{github.workspace}}/build/CalChart.tar.xz .
- name: Upload
uses: actions/upload-artifact@v4
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-24.04
needs: build
steps:
- name: checkout
uses: actions/checkout@v3
- name: Download artifact
uses: actions/download-artifact@v4
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 }}