-
Notifications
You must be signed in to change notification settings - Fork 124
329 lines (277 loc) · 11.1 KB
/
main.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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
name: main
on:
push:
# Only build branches on push, tags will be handled by 'release' job.
branches:
- '**'
pull_request:
workflow_dispatch:
release:
types: [created]
jobs:
build:
strategy:
matrix:
include:
- os: windows-latest
configurePreset: msbuild-x64
buildPreset: msbuild-x64-release
name: ezQuake-windows-x64
artifact: "ezquake.exe"
container: null
- os: macos-latest
configurePreset: macos-arm64
buildPreset: macos-arm64-release
name: ezQuake-macOS-arm64
artifact: "ezQuake.zip"
packages: ["autoconf", "automake", "libtool"]
container: null
- os: macos-latest
configurePreset: macos-x64
buildPreset: macos-x64-release
name: ezQuake-macOS-x64
artifact: "ezQuake.zip"
packages: ["autoconf", "automake", "libtool"]
container: null
- os: ubuntu-latest
configurePreset: dynamic
buildPreset: dynamic-release
name: ezQuake-linux-x86_64
artifact: "ezQuake-x86_64.AppImage"
cflags: "-march=nehalem"
packages: ["build-essential", "ca-certificates", "cmake", "curl", "file", "git", "libcurl4-openssl-dev", "libexpat1-dev", "libfreetype-dev", "libfuse2", "libjansson-dev", "libjpeg-dev", "libminizip-dev", "libpcre2-dev", "libpng-dev", "libsdl2-2.0-0", "libsdl2-dev", "libsndfile1-dev", "libspeex-dev", "libspeexdsp-dev", "ninja-build", "unzip"]
container:
image: debian:testing
options: --privileged
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Prepare Linux environment
run: |
apt-get -qq update && apt-get -qq install --no-install-recommends ${{ join(matrix.packages, ' ') }}
git config --global --add safe.directory $PWD
if: matrix.os == 'ubuntu-latest'
- name: Prepare macOS environment
run: brew install -q ${{ join(matrix.packages, ' ') }}
if: matrix.os == 'macos-latest'
- name: Check out code
uses: actions/checkout@v4
with:
submodules: true
# To get correct revision which is needed by server to detect certain client bugs
fetch-depth: 0
- name: Fetch upstream tags for version metadata
run: |
git remote add upstream /~https://github.com/QW-Group/ezquake-source.git
git fetch --tags --no-recurse-submodules upstream
if: github.repository != 'QW-Group/ezquake-source'
- name: Set library build type to release
shell: bash
run: |
# Hopefully overrideable via environment in the future. Done here as
# vcpkg is chainloaded before cmake, and doesn't seem to apply args.
# Avoids building both -dbg and -rel versions of static libraries.
for x in {cmake/triplets/*,vcpkg/triplets/{*,community/*}}; do
if [[ -f $x ]]; then
echo >> $x
echo 'set(VCPKG_BUILD_TYPE release)' >> $x
fi
done
if: matrix.os != 'ubuntu-latest'
- uses: lukka/get-cmake@latest
with:
cmakeVersion: "~3.28.0"
if: matrix.os != 'ubuntu-latest'
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
if: matrix.os != 'ubuntu-latest'
- name: Run CMake
uses: lukka/run-cmake@v10
with:
configurePreset: ${{ matrix.configurePreset }}
buildPreset: ${{ matrix.buildPreset }}
env:
CFLAGS: ${{ matrix.cflags }}
- name: Generate Linux AppImage
run: |
export EXECUTABLE=$(echo build-${{ matrix.configurePreset }}/Release/ezquake*)
./misc/appimage/appimage-manual_creation.sh
mv ezQuake-x86_64.AppImage build-${{ matrix.configurePreset }}/Release/
if: matrix.os == 'ubuntu-latest'
- name: Preserve macOS executable bit
run: |
zip -r -9 ezQuake.zip ezQuake.app
working-directory: build-${{ matrix.configurePreset }}/Release
if: matrix.os == 'macos-latest'
- name: Archive client
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: |
build-${{ matrix.configurePreset }}/Release/${{ matrix.artifact }}
compression-level: 9
macos-universal:
needs: build
name: "ezQuake-macOS-universal"
runs-on: macos-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Download ARM64 Build
uses: actions/download-artifact@v4
with:
name: ezQuake-macOS-arm64
path: artifacts/arm64
- name: Download Intel Build
uses: actions/download-artifact@v4
with:
name: ezQuake-macOS-x64
path: artifacts/x64
- name: Create Universal Binary
run: |
(cd artifacts/x64 && unzip -qq ezQuake.zip) && (cd artifacts/arm64 && unzip -qq ezQuake.zip)
cp -r artifacts/arm64/ezQuake.app .
lipo -create -output ezQuake.app/Contents/MacOS/ezQuake \
artifacts/x64/ezQuake.app/Contents/MacOS/ezQuake \
artifacts/arm64/ezQuake.app/Contents/MacOS/ezQuake
codesign --force --sign - --entitlements dist/macOS/ezquake.entitlements.plist --options runtime --timestamp ezQuake.app
zip -r ezQuake-macOS-universal.zip ezQuake.app
- name: Delete macOS arch specific builds
uses: geekyeggo/delete-artifact@v5
with:
name: |
ezQuake-macOS-arm64
ezQuake-macOS-x64
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: ezQuake-macOS-universal
path: ezQuake-macOS-universal.zip
compression-level: 9
upload:
if: github.repository == 'QW-group/ezquake-source' && ((github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'release')
needs: [macos-universal]
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Checkout
uses: actions/checkout@v4
with:
path: ezquake
submodules: true
# To get correct revision when generating version.json for source release tarball
fetch-depth: 0
if: github.event_name == 'release'
- name: Get release date
run: |
RELEASE_DATE=$(git log -1 --format=%cI "${{ github.ref_name }}")
echo "RELEASE_DATE=$RELEASE_DATE" >> $GITHUB_ENV
working-directory: ezquake
if: github.event_name == 'release'
- name: Collect GitHub release artifacts
run: |
set -e
dist_dir="${GITHUB_WORKSPACE}/dist"
mkdir "${dist_dir}"
# Reset timestamp to time of commit before compression
find "artifacts" -type f -exec touch --date="${RELEASE_DATE}" {} +
# Set executable bit for all files
find "artifacts" -type f -exec chmod 755 {} +
# Recompress before attaching to release, avoiding double-zip of macOS
(
cd artifacts
for target in *; do
if ls "${target}"/*.zip &> /dev/null; then
cp "${target}"/*.zip "${dist_dir}/${target}.zip"
else
(cd "${target}"; zip -o -9 "${dist_dir}/${target}.zip" *)
fi
done;
)
# Generate source release with submodule, version.json etc
(
cd "${GITHUB_WORKSPACE}/ezquake"
dist/gen-release.sh
mv *.tar.gz "${dist_dir}/"
)
find "${dist_dir}" -type f -execdir sha256sum {} \; > "checksums.txt"
mv "checksums.txt" "${dist_dir}/"
# Reset timestamp to time of commit for all release artifacts
find "${dist_dir}" -type f -exec touch --date="${RELEASE_DATE}" {} +
echo "Release artifacts:"
ls -lR "${dist_dir}"
echo "Checksums:"
cat "${dist_dir}/checksums.txt"
echo "GITHUB_ARTIFACTS=$dist_dir" >> $GITHUB_ENV
if: github.event_name == 'release'
- name: Attach artifacts to GitHub release
uses: softprops/action-gh-release@v2
with:
files: ${{ env.GITHUB_ARTIFACTS }}/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'release'
- name: Prepare Upload Environemnt
run: |
sudo apt-get -qq update
sudo apt-get -qq --no-install-recommends install openssh-client
- name: Setup SSH
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
- name: Prepare upload to builds.quakeworld.nu
run: |
# Build file structure for uploading
# snapshots:
# upload/snapshots/latest/$os/$arch/$filename
# upload/snapshots/$os/$arch/$prefix_$filename
# releases:
# upload/releases/latest/$os/$arch/$filename
# upload/releases/$tag/$os/$arch/$filename
set -e
upload_dir="${GITHUB_WORKSPACE}/upload"
if [[ $GITHUB_REF == refs/tags/* ]]; then
main_dir="${upload_dir}/releases/${{ github.ref_name }}"
latest_dir="${upload_dir}/releases/latest"
prefix=""
upload_prefix="releases"
else
main_dir="${upload_dir}/snapshots"
latest_dir="${upload_dir}/snapshots/latest"
date=$(TZ="Europe/Amsterdam" date "+%Y%m%d-%H%M%S")
prefix="${date}_${GITHUB_SHA::7}_"
upload_prefix="snapshots"
fi
# Collect upload structure
for artifact in artifacts/*/*; do
artifact_file=$(basename "${artifact}")
artifact_dir=$(dirname "${artifact}")
IFS='-' read -r ezq os arch <<< "${artifact_dir}"
mkdir -p "${main_dir}/${os}/${arch}" "${latest_dir}/${os}/${arch}"
cp "${artifact}" "${main_dir}/${os}/${arch}/${prefix}${artifact_file}"
cp "${artifact}" "${latest_dir}/${os}/${arch}/${artifact_file}"
done
# Set executable bit for all files
find "${upload_dir}" -type f -exec chmod 755 {} +
# Generate checksums
for artifact in $(find "${upload_dir}" -type f); do
artifact_file=$(basename "${artifact}")
artifact_dir=$(dirname "${artifact}")
(cd "${artifact_dir}" && md5sum "${artifact_file}" > "${artifact_file}.md5")
done
# Reset timestamp to time of commit
find "${upload_dir}" -type f -exec touch --date="${RELEASE_DATE}" {} +
echo "Upload artifacts:"
ls -lR "${upload_dir}"
echo "UPLOAD_PREFIX=${upload_prefix}" >> $GITHUB_ENV
- name: Upload to builds.quakeworld.nu
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
sftp -rp -o 'StrictHostKeyChecking no' -o 'UserKnownHostsFile /dev/null' -P ${{ secrets.SFTP_PORT }} ${{ secrets.SFTP_USERNAME }}@${{ secrets.SFTP_HOST }}:/${{ env.UPLOAD_PREFIX }} <<< $'put -rp upload/${{ env.UPLOAD_PREFIX }}/*'