-
Notifications
You must be signed in to change notification settings - Fork 40
268 lines (225 loc) · 8.44 KB
/
compilation.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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
name: CI
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
repository_dispatch:
types: [run_build]
jobs:
# Check code formatting correctness
# -----------------------------------------------------------------------------------------------
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check
uses: jidicula/clang-format-action@v4.5.0
with:
clang-format-version: '13'
# Run unittests on modern-ish versions of gcc and clang.
# -----------------------------------------------------------------------------------------------
unittest:
name: Run unit-tests on ${{ matrix.config.name }}
runs-on: ubuntu-24.04
env:
CC: ${{ matrix.config.cc }}
strategy:
fail-fast: false
matrix:
config:
- { name: "gcc 13", cc: gcc-13, tidy: "On" }
- { name: "clang 15", cc: clang-15, tidy: "Off" }
steps:
- uses: actions/checkout@v4
- name: Install Ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get -y install cmake cmake-data libargtable2-dev libcunit1-dev \
libsdl2-mixer-dev libconfuse-dev libenet-dev libsdl2-dev libxmp-dev libpng-dev \
clang-tidy ${{ matrix.config.cc }}
- name: Build tests
run: |
mkdir build-test && cd build-test
cmake -DCMAKE_BUILD_TYPE=Debug \
-DUSE_TIDY=${{ matrix.config.tidy }} \
-DUSE_TESTS=On \
-DUSE_TOOLS=On ..
make -j2
- name: Run tests
run: |
cd build-test
make test ARGS="-V"
# Build ubuntu package, release artifact and update "latest" release if necessary.
# -----------------------------------------------------------------------------------------------
build_ubuntu:
needs: [unittest, formatting-check]
name: Build ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get -y install cmake libargtable2-dev libcunit1-dev libsdl2-mixer-dev \
libconfuse-dev libenet-dev libsdl2-dev libxmp-dev libpng-dev
- name: Generate Release
run: |
mkdir build-release && cd build-release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=release ..
make -j2
make install
- name: Get short SHA
id: slug
run: echo "sha8=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_OUTPUT
- name: Generate TGZ package
run: tar cvfz ${GITHUB_WORKSPACE}/openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_linux_amd64.tar.gz -C build-release/release/ .
- name: Upload TGZ artifact
uses: actions/upload-artifact@v3
with:
name: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_linux_amd64
path: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_linux_amd64.tar.gz
- name: Generate DEB package
uses: jiro4989/build-deb-action@v2
with:
package: openomf
package_root: build-release/release
maintainer: ${{ github.repository_owner }}
version: 0.6.6-${{ steps.slug.outputs.sha8 }}
arch: 'amd64'
depends: 'libargtable2, libsdl2-mixer, libconfuse, libenet, libsdl2, libxmp, libpng'
desc: 'One Must Fall 2097 Remake'
- name: Upload DEB artifact
uses: actions/upload-artifact@v3
with:
name: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_deb_amd64
path: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_amd64.deb
# Build macos package, release artifact and update "latest" release if necessary.
# -----------------------------------------------------------------------------------------------
build_macos:
needs: [unittest, formatting-check]
name: Build macos-12
runs-on: macos-12
steps:
- uses: actions/checkout@v4
- name: Install Mac Dependencies
run: |
brew update
brew install cmake argtable cunit sdl2_mixer confuse enet sdl2 libxmp libpng
- name: Generate Release
run: |
mkdir build-release && cd build-release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=release ..
make -j3
make install
- name: Get short SHA
id: slug
run: echo "sha8=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_OUTPUT
- name: Generate ZIP package
run: |
cd build-release/release
zip -r ${GITHUB_WORKSPACE}/openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos12.zip .
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos12
path: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos12.zip
# Build windows package, release artifact and update "latest" release if necessary.
# -----------------------------------------------------------------------------------------------
build_windows:
needs: [unittest, formatting-check]
name: Build windows-amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get -y install mingw-w64 unzip
wget -q https://github.com/omf2097/openomf-win-build/archive/refs/heads/main.zip
unzip -q main.zip && rm main.zip
- name: Generate Windows Release
run: |
mkdir build-release && cd build-release
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=release \
-DCMAKE_TOOLCHAIN_FILE="${GITHUB_WORKSPACE}/cmake-scripts/mingw-w64-toolchain.cmake" \
-DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/openomf-win-build-main/" \
-DCMAKE_INCLUDE_PATH="${GITHUB_WORKSPACE}/openomf-win-build-main/include/" \
-DCMAKE_LIBRARY_PATH="${GITHUB_WORKSPACE}/openomf-win-build-main/lib/" \
-DCMAKE_FIND_ROOT_PATH="${GITHUB_WORKSPACE}/openomf-win-build-main/" \
"${GITHUB_WORKSPACE}"
make -j2
make install
cp ${GITHUB_WORKSPACE}/openomf-win-build-main/bin/*.dll release/openomf/
- name: Get short SHA
id: slug
run: echo "sha8=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_OUTPUT
- name: Generate ZIP package
run: |
cd build-release/release
zip -r ${GITHUB_WORKSPACE}/openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_windows_amd64.zip openomf
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_windows_amd64
path: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_windows_amd64.zip
# Create a "latest" release
# -----------------------------------------------------------------------------------------------
make_release:
needs: [build_windows, build_macos, build_ubuntu]
if: github.ref == 'refs/heads/master'
name: Make "latest" release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: actions/download-artifact@v3
with:
path: artifacts/
- name: Advance tag
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
try {
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/latest"
})
} catch (e) {
console.log("The 'latest' tag doesn't exist yet", e)
}
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/latest",
sha: context.sha
})
} catch (e) {
console.log("Unable to create 'latest' tag", e)
}
- name: Extract ubuntu releases
run: |
mkdir upload
shopt -s globstar
for file in artifacts/**; do
if [ -f "$file" ]; then
cp "$file" "${GITHUB_WORKSPACE}/upload/"
fi
done
- uses: ncipollo/release-action@v1
with:
artifacts: "upload/*"
body: "Latest release from master. Note that this is autogenerated release, and should only be used for testing purposes."
name: Latest
tag: latest
allowUpdates: true
prerelease: true
removeArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}