forked from colobot/colobot
-
Notifications
You must be signed in to change notification settings - Fork 1
229 lines (225 loc) · 10.1 KB
/
build.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
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
name: Build
on: [push, pull_request]
jobs:
build-linux:
runs-on: ${{ matrix.host_os }}
container: ${{ matrix.container }}
strategy:
matrix:
target_os: [linux]
host_os: [ubuntu-20.04, ubuntu-22.04]
container: ['']
include:
- host_os: ubuntu-22.04
container: 'debian:unstable-slim'
- host_os: ubuntu-22.04
container: 'debian:testing-slim'
fail-fast: false
env:
# Actions run as root in-container, as normal user outside
SUDO: ${{ matrix.container == '' && 'sudo' || '' }}
# Shortcuts the autodetection
DEBIAN_FRONTEND: noninteractive
# Only build the appImage
APPIMAGE: ${{ matrix.host_os == 'ubuntu-20.04' }}
steps:
- name: Install back toolchain with gcc-11 available
run: $SUDO add-apt-repository ppa:ubuntu-toolchain-r/test -y && $SUDO apt-get update -y
if: matrix.host_os == 'ubuntu-20.04'
- name: Install various indirect dependencies in slim containers
run: $SUDO apt-get update && $SUDO apt-get install -y --no-install-recommends git ca-certificates wget
if: matrix.container != ''
- name: Switch to gcc-11
run: $SUDO apt-get install gcc-11 g++-11 && $SUDO update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 && $SUDO update-alternatives --set gcc /usr/bin/gcc-11
if: matrix.host_os == 'ubuntu-20.04'
- name: Install Colobot dependencies
run: $SUDO apt-get update && $SUDO apt-get install -y --no-install-recommends build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsndfile1-dev libvorbis-dev libogg-dev libpng-dev libglew-dev libopenal-dev libphysfs-dev gettext po4a vorbis-tools librsvg2-bin xmlstarlet libglm-dev libmpg123-dev
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install recent libgtest-dev and nlohmann-json3-dev to replace the local submodules
run: $SUDO apt-get update && $SUDO apt-get install -y --no-install-recommends libgtest-dev nlohmann-json3-dev && rm -Rf lib/googletest lib/json
if: matrix.container != '' || matrix.host_os == 'ubuntu-22.04'
- name: Create build directory
run: cmake -E make_directory build
- name: Run CMake (for Linux)
run: cmake --preset Linux-CI
- name: Build
run: cmake --build --preset Linux-CI
- name: Install
run: cmake --build --preset Linux-CI --target install
- name: Patch library path to prepare for appimage
run: patchelf --set-rpath '.' install/colobot
if: ${{ env.APPIMAGE == true }}
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: ${{matrix.target_os}}-debug
path: install
if: ${{ env.APPIMAGE == true }}
- name: Create AppImage
working-directory: build
run: |
# Download app image tool
wget -N https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
./linuxdeploy-x86_64.AppImage --appimage-extract
# Create AppImage
NO_STRIP=1 ./squashfs-root/AppRun -e colobot --output appimage --appdir colobot.AppDir -d desktop/colobot.desktop -i ../desktop/colobot.svg
chmod +x Colobot-x86_64.AppImage
# Prepare folder for zip
mkdir -p appimage
cp -rp ../install/data appimage/data
cp -rp ../install/lang appimage/lang
cp -p Colobot-x86_64.AppImage appimage/colobot
if: ${{ env.APPIMAGE == true }}
- name: Upload AppImage
uses: actions/upload-artifact@v3
with:
name: ${{matrix.target_os}}-debug-AppImage
path: build/appimage
if: ${{ env.APPIMAGE == true }}
- name: Run tests
# TODO: Maybe run Windows tests using wine as well?
working-directory: build
run: ./Colobot-UnitTests --gtest_output=xml:gtestresults.xml
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: Test results (${{ matrix.target_os }}, ${{ matrix.host_os }})
path: build/gtestresults.xml
build-macos:
runs-on: ${{ matrix.host_os }}
container: ${{ matrix.container }}
strategy:
matrix:
target_os: [macos]
host_os: [macos-12, macos-13]
container: ['']
fail-fast: false
steps:
- name: Install Colobot dependencies
run: brew install cmake sdl2 sdl2_image sdl2_ttf glew physfs flac libsndfile libvorbis vorbis-tools gettext libicns librsvg wget xmlstarlet glm
if: matrix.container == ''
- uses: actions/checkout@v3
- name: Checkout the Google Test submodule
run: git submodule update --init -- lib/googletest
- name: Checkout the nlohmann json submodule
run: git submodule update --init -- lib/json
- name: Create build directory
run: cmake -E make_directory build
- name: Run CMake (for Mac)
run: cmake --preset MacOS-CI
if: matrix.target_os == 'macos'
- name: Build
run: cmake --build --preset MacOS-CI
- name: Run tests
# TODO: Maybe run Windows tests using wine as well?
working-directory: build
run: ./Colobot-UnitTests --gtest_output=xml:gtestresults.xml
if: matrix.target_os == 'macos'
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: Test results (${{ matrix.target_os }}, ${{ matrix.host_os }})
path: build/gtestresults.xml
if: matrix.target_os == 'macos'
build-windows:
runs-on: windows-2019
strategy:
matrix:
include:
- arch: amd64
vcpkg_triplet: 'x64-windows-static'
- arch: x86
vcpkg_triplet: 'x86-windows-static'
steps:
- uses: actions/checkout@v3
- name: Checkout the Google Test submodule
run: git submodule update --init -- lib/googletest
- name: Checkout the nlohmann json submodule
run: git submodule update --init -- lib/json
- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@master
- name: Setup VS Environment
uses: seanmiddleditch/gha-setup-vsdevenv@master
with:
arch: ${{ matrix.arch }}
- name: Install Colobot dependencies
uses: lukka/run-vcpkg@v7
with:
setupOnly: true
vcpkgGitCommitId: 'f6a5d4e8eb7476b8d7fc12a56dff300c1c986131'
vcpkgTriplet: ${{ matrix.vcpkg_triplet }}
# SHA-256 hash of the vcpkg.json file, recalculated automatically when it changes
appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}
additionalCachedPaths: ${{ github.workspace }}/build/vcpkg_installed
- name: Install external tools
working-directory: ${{ github.workspace }}
run: |
echo "Downloading gettext..."
(New-Object System.Net.WebClient).DownloadFile("https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.20.2-v1.16/gettext0.20.2-iconv1.16-static-64.zip", "gettext.zip");
echo "Unpacking gettext..."
7z x -ogettext gettext.zip;
echo "Adding gettext to PATH..."
echo "${{ github.workspace }}\gettext\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "Downloading xmlstarlet..."
(New-Object System.Net.WebClient).DownloadFile("https://downloads.sourceforge.net/project/xmlstar/xmlstarlet/1.6.1/xmlstarlet-1.6.1-win32.zip", "xmlstarlet.zip");
echo "Unpacking xmlstarlet..."
7z x -oxmlstarlet xmlstarlet.zip;
echo "Renaming xml.exe to xmlstarlet.exe"
Rename-Item -Path "${{ github.workspace }}\xmlstarlet\xmlstarlet-1.6.1\xml.exe" -NewName "xmlstarlet.exe"
echo "Adding xmlstarlet to PATH..."
echo "${{ github.workspace }}\xmlstarlet\xmlstarlet-1.6.1" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "Downloading rsvg-convert..."
(New-Object System.Net.WebClient).DownloadFile("https://downloads.sourceforge.net/project/tumagcc/rsvg-convert-2.40.20.7z", "rsvg-convert.zip");
echo "Unpacking xmlstarlet..."
7z x -orsvg-convert rsvg-convert.zip;
echo "Adding rsvg-convert to PATH..."
echo "${{ github.workspace }}\rsvg-convert" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: pwsh
- name: Create build directory
run: cmake -E make_directory build
- name: Run CMake (for Windows)
run: cmake --preset Windows-CI -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }} -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}\scripts\buildsystems\vcpkg.cmake
- name: Build
run: |
$nproc = (Get-CIMInstance -Class 'CIM_Processor').NumberOfLogicalProcessors
cmake --build --preset Windows-CI -j $nproc
shell: pwsh
- name: Install
run: cmake --build --preset Windows-CI --target install
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: windows-msvc-debug-${{ matrix.arch }}
path: install
- name: Run tests
working-directory: build
run: ./Colobot-UnitTests --gtest_output=xml:gtestresults.xml
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: 'Test results (windows, MSVC, ${{ matrix.arch }})'
path: build/gtestresults.xml
doc:
runs-on: ubuntu-latest
steps:
- name: Install Colobot dependencies
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsndfile1-dev libvorbis-dev libogg-dev libpng-dev libglew-dev libopenal-dev libphysfs-dev gettext git po4a vorbis-tools librsvg2-bin xmlstarlet doxygen graphviz libglm-dev libmpg123-dev
- uses: actions/checkout@v3
- name: Create build directory
run: cmake -E make_directory build
- name: Checkout the nlohmann json submodule
run: git submodule update --init -- lib/json
- name: Run CMake
working-directory: build
run: cmake ..
- name: Build docs
working-directory: build
run: make doc
- name: Upload docs
uses: actions/upload-artifact@v3
with:
name: doc
path: build/doc