-
Notifications
You must be signed in to change notification settings - Fork 1
196 lines (167 loc) · 6.3 KB
/
cmake-multi-platform.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
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
name: CI/CD
on:
push:
branches: [ "main" ]
tags:
- '*'
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, cl]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
exclude:
- os: windows-latest
c_compiler: gcc
- os: ubuntu-latest
c_compiler: cl
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # complete history
fetch-tags: true
- name: Get Git Tag Linux
id: tags
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Get Git Tag Windows
id: tags_win
run: |
$tag = $env:GITHUB_REF -replace 'refs/tags/', ''
echo "::set-output name=tag::$tag"
shell: pwsh
- name: Install Qt6 dependencies for Windows
if: runner.os == 'Windows'
uses: jurplel/install-qt-action@v4.0.0
with:
aqtversion: '==3.1.*'
version: '6.6.1'
host: 'windows'
target: 'desktop'
arch: 'win64_msvc2019_64'
modules: 'qtcharts qtmultimedia'
- name: Install Qt6 dependencies for Linux
if: runner.os == 'Linux'
uses: jurplel/install-qt-action@v4.0.0
with:
aqtversion: '==3.1.*'
version: '6.6.3'
host: 'linux'
target: 'desktop'
arch: 'gcc_64'
modules: 'qtcharts qtmultimedia'
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake for Windows
if: runner.os == 'Windows'
run: |
cmake -B ${{ steps.strings.outputs.build-output-dir }} `
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} `
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} `
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} `
-DCMAKE_PREFIX_PATH=${{ env.Qt6_DIR }} `
-DCMAKE_IS_GITHUB_WORKFLOW=ON `
-S ${{ github.workspace }}
- name: Configure CMake for Linux
if: runner.os == 'Linux'
run: |
cmake -B ${{ steps.strings.outputs.build-output-dir }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_PREFIX_PATH=/usr/lib/qt6 \
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}/tests
run: ctest --build-config ${{ matrix.build_type }}
- name: Install Build Output
run: cmake --install ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --strip
- name: Compress Build Output
if: startsWith(github.ref, 'refs/tags/')
run: |
if [ "${{ runner.os }}" == "Linux" ]; then
cd ${{ steps.strings.outputs.build-output-dir }}/install && tar -cvzf ../../dartomato-build-${{ matrix.os }}-${{ matrix.build_type }}-${{ steps.tags.outputs.tag }}.tar.gz *
else
pwsh -Command "Compress-Archive -Path '${{ steps.strings.outputs.build-output-dir }}/bin/*' -DestinationPath 'dartomato-build-${{ matrix.os }}-${{ matrix.build_type }}-${{ steps.tags_win.outputs.tag }}.zip'"
fi
shell: bash
- name: Upload Artifacts
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: dartomato-build-${{ matrix.os }}-${{ matrix.build_type }}-${{ runner.os == 'Linux' && steps.tags.outputs.tag || steps.tags_win.outputs.tag }}
path: dartomato-build-${{ matrix.os }}-${{ matrix.build_type }}-${{ runner.os == 'Linux' && steps.tags.outputs.tag || steps.tags_win.outputs.tag }}.${{ runner.os == 'Linux' && 'tar.gz' || 'zip' }}
deploy:
if: startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Get Git Tag Linux
id: tags
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Get Git Tag Windows
id: tags_win
run: |
$tag = $env:GITHUB_REF -replace 'refs/tags/', ''
echo "::set-output name=tag::$tag"
shell: pwsh
- name: Download Linux Artifacts
uses: actions/download-artifact@v4
with:
name: dartomato-build-ubuntu-latest-Release-${{ steps.tags.outputs.tag }}
path: ./linux/
- name: Download Windows Artifacts
uses: actions/download-artifact@v4
with:
name: dartomato-build-windows-latest-Release-${{ steps.tags_win.outputs.tag }}
path: ./windows/
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: "Release ${{ github.ref }}"
draft: false
prerelease: false
- name: Upload Linux Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./linux/dartomato-build-ubuntu-latest-Release-${{ steps.tags.outputs.tag }}.tar.gz
asset_name: dartomato-build-ubuntu-latest-Release-${{ steps.tags.outputs.tag }}.tar.gz
asset_content_type: application/gzip
- name: Upload Windows Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./windows/dartomato-build-windows-latest-Release-${{ steps.tags_win.outputs.tag }}.zip
asset_name: dartomato-build-windows-latest-Release-${{ steps.tags_win.outputs.tag }}.zip
asset_content_type: application/zip