-
Notifications
You must be signed in to change notification settings - Fork 0
251 lines (215 loc) · 7.41 KB
/
cmake.yml
File metadata and controls
251 lines (215 loc) · 7.41 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: CMake
on:
push:
branches:
- main
env:
BUILD_TYPE: Release
JSON_VERSION: 3.11.2
BOOST_VERSION: 1.81.0
jobs:
build:
strategy:
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
- windows-2019
include:
- os: ubuntu-20.04
os_version: 20.04
build_tool: gcc
- os: ubuntu-22.04
os_version: 22.04
build_tool: gcc
- os: windows-2019
os_version: 2022
build_tool: msvc142
runs-on: ${{ matrix.os }}
outputs:
release_version: ${{ steps.configure-ubuntu.outputs.release_version }}
steps:
- uses: actions/checkout@v3
- uses: suisei-cn/[email protected]
name: Download bithacks.h
with:
url: "https://raw.githubusercontent.com/pkrumins/bithacks.h/master/bithacks.h"
target: third_party/
- uses: suisei-cn/[email protected]
name: Download debug-trap.h
with:
url: "https://raw.githubusercontent.com/nemequ/portable-snippets/master/debug-trap/debug-trap.h"
target: third_party/
- uses: suisei-cn/[email protected]
name: Download propagate_const.h
with:
url: "https://raw.githubusercontent.com/jbcoe/propagate_const/master/propagate_const.h"
target: third_party/
- uses: suisei-cn/[email protected]
name: Download json.hpp
with:
url: "https://github.com/nlohmann/json/releases/download/v${{ env.JSON_VERSION }}/json.hpp"
target: third_party/
# Retrieve the cache, uses cache@v3
- name: Cache boost
uses: actions/cache@v3
id: cache-boost
with:
# Set the default path as the path to cache
path: '${{ runner.workspace }}/boost_*.tar.gz'
# Use the version as the key to only cache the correct version
key: boost-${{ env.BOOST_VERSION }}
- name: Install boost
uses: egor-tensin/build-boost@v1
id: install-boost
with:
version: ${{ env.BOOST_VERSION }}
toolset: ${{ matrix.build_tool }}
libraries: system
- name: Bundle Include Files
if: matrix.os == 'ubuntu-20.04'
run: zip includes.zip include/* third_party/* -r
- name: Upload Include Bundle
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v2
with:
name: release-libs
path: includes.zip
retention-days: 1
- name: Setup Ubuntu
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04'
run: |
sudo apt install libgtest-dev
- name: Configure CMake Ubuntu
id: configure-ubuntu
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04'
run: |
mkdir build
cd build
mkdir ubuntu
cd ubuntu
cmake ../../ -DBOOST_INCLUDE_DIR=${{ steps.install-boost.outputs.root }} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
APPLICATION_VERSION=$(grep CMAKE_PROJECT_VERSION: CMakeCache.txt | cut -d "=" -f2)
echo "::set-output name=release_version::$APPLICATION_VERSION"
- name: Build Ubuntu
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04'
run: |
cd build/ubuntu
cmake --build .
- name: Test Ubuntu
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04'
run: |
cd build/ubuntu
ctest
- name: Setup Windows
id: setup-windows
if: matrix.os == 'windows-2019'
run: |
git clone https://github.com/google/googletest.git googletest
cd googletest
mkdir msvc
cd msvc
cmake ../ -Dgtest_force_shared_crt=ON
cmake --build . --config Release
echo "::set-output name=google_test_include_dir::googletest/googletest/include"
echo "::set-output name=google_test_library_dir::googletest/msvc/lib/Release"
- name: Configure CMake Windows
if: matrix.os == 'windows-2019'
run: |
mkdir build
cd build
mkdir windows
cd windows
cmake ../../ -DBOOST_INCLUDE_DIR=${{ steps.install-boost.outputs.root }} -DMSVC=1 -DGTEST_INCLUDE_DIR=${{ steps.setup-windows.outputs.google_test_include_dir }} -DGTEST_LIBRARY_DIR=${{ steps.setup-windows.outputs.google_test_library_dir }}
- name: Build Windows
if: matrix.os == 'windows-2019'
run: |
cd build/windows
cmake --build . --config ${{env.BUILD_TYPE}}
- name: Test Windows
if: matrix.os == 'windows-2019'
run: |
cd build/windows
ctest
- name: Archive Ubuntu 20 generated files
if: matrix.os == 'ubuntu-20.04'
shell: pwsh
run: Compress-Archive -DestinationPath build/ubuntu/ubuntu20.04.zip -Path build/ubuntu/libLowLevel.a
- name: Upload Ubuntu 20 Library
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v2
with:
name: release-libs
path: build/ubuntu/ubuntu20.04.zip
retention-days: 1
- name: Archive Ubuntu 22 generated files
if: matrix.os == 'ubuntu-22.04'
shell: pwsh
run: Compress-Archive -DestinationPath build/ubuntu/ubuntu22.04.zip -Path build/ubuntu/libLowLevel.a
- name: Upload Ubuntu 22 Library
if: matrix.os == 'ubuntu-22.04'
uses: actions/upload-artifact@v2
with:
name: release-libs
path: build/ubuntu/ubuntu22.04.zip
retention-days: 1
- name: Archive Windows generated files
if: matrix.os == 'windows-2019'
shell: pwsh
run: Compress-Archive -DestinationPath build/windows/windows.zip -Path build/windows/Release/LowLevel.lib
- name: Upload Windows Library
if: matrix.os == 'windows-2019'
uses: actions/upload-artifact@v3
with:
name: release-libs
path: build/windows/windows.zip
retention-days: 1
release:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Previous Tag
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@v1
with:
fallback: '3.18.1.0'
- name: Tag the repository
run: |
git config user.name github-actions
git config user.email [email protected]
RELEASE_TAG=${{ needs.build.outputs.release_version }}
git tag -a $RELEASE_TAG -m "Release on $(date +'%Y-%m-%d') for commit $(git rev-parse HEAD)"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true
- name: Download Libraries
uses: actions/download-artifact@v3
with:
name: release-libs
- name: Create Release Notes
id: build-notes
uses: mikepenz/[email protected]
with:
toTag: ${{ needs.build.outputs.release_version }}
fromTag: ${{ steps.previoustag.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
uses: softprops/action-gh-release@v1
with:
name: ${{ needs.build.outputs.release_version }}
body: ${{ steps.build-notes.outputs.changelog }}
files: |
windows.zip
ubuntu22.04.zip
ubuntu20.04.zip
includes.zip
tag_name: refs/tags/${{ needs.build.outputs.release_version }}