-
Notifications
You must be signed in to change notification settings - Fork 2
338 lines (323 loc) · 13.5 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
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
330
331
332
333
334
335
336
name: Build and upload Latest Release
on: [push, pull_request]
env:
GIT_PAGER:
BUILD_TYPE: Release
jobs:
#### Prepare build definitions
get_release_definitions:
name: Get Release definitions
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
filter: "blob:none"
fetch-tags: 'true'
fetch-depth: '1000'
submodules: 'true'
- name: Define Release Strategy
id: DefineReleaseStrategy
run: |
pip install python-kacl
# GIT_REV_NAME: as seen in https://stackoverflow.com/a/11489642
# Creates a Stable Release only if tags are pushed at the same time as the relevant commit:
# git push origin <my branch> --tags
# Tag can be lightweight or annotated.
GIT_REV_NAME=$(git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true | sed -n 's/^\([^^~]\{1,\}\)\(\^0\)\{0,1\}$/\1/p')
echo "############### GIT_REV_NAME = ${GIT_REV_NAME}"
# Stable Release: regex checks exact match to '^v<maj>.<min>.<patch>$'
if [[ "xxx${GIT_REV_NAME}" =~ ^xxxv[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "############### Matched an exact Stable Release Tag"
RELEASE_TAG="${GIT_REV_NAME}"
RELEASE_DESCR="Stable Release"
RELEASE_PRERELEASE="false"
kacl-cli get ${GIT_REV_NAME:1} > RELEASE_LOG.md \
|| echo "Release description unavailable" > RELEASE_LOG.md
elif [[ "xxx${GIT_REV_NAME}" =~ ^xxxv[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "############### Matched an RC Release Tag"
RELEASE_TAG="${GIT_REV_NAME}"
RELEASE_DESCR="Release Candidate"
RELEASE_PRERELEASE="true"
kacl-cli get ${GIT_REV_NAME:1} > RELEASE_LOG.md \
|| echo "Release description unavailable" > RELEASE_LOG.md
else
echo "############### Unmatched release Tags, going to 'latest'"
kacl-cli get unreleased > RELEASE_LOG.md \
|| echo "Release description unavailable" > RELEASE_LOG.md
RELEASE_TAG="latest"
RELEASE_DESCR="Development Release"
RELEASE_PRERELEASE="true"
fi
echo "############### RELEASE_TAG = ${RELEASE_TAG}"
echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_OUTPUT
echo "############### RELEASE_DESCR = ${RELEASE_DESCR}"
echo "RELEASE_DESCR=${RELEASE_DESCR}" >> $GITHUB_OUTPUT
echo "############### RELEASE_PRERELEASE = ${RELEASE_PRERELEASE}"
echo "RELEASE_PRERELEASE=${RELEASE_PRERELEASE}" >> $GITHUB_OUTPUT
echo "############### showing all known tags"
git tag
echo "############### Building version '${RELEASE_TAG}'"
- name: Upload Artifact
uses: actions/upload-artifact@v3
if: github.ref == 'refs/heads/main'
with:
retention-days: 1
name: definitions
path: RELEASE_LOG.md
outputs:
RELEASE_TAG: ${{ steps.DefineReleaseStrategy.outputs.RELEASE_TAG }}
RELEASE_DESCR: ${{ steps.DefineReleaseStrategy.outputs.RELEASE_DESCR }}
RELEASE_PRERELEASE: ${{ steps.DefineReleaseStrategy.outputs.RELEASE_PRERELEASE }}
#### Linux x86_64
build_x86_64:
if: ${{ github.event.inputs.job_enabled_x86_64 != 'false' }}
name: Build Linux x86_64 on Ubuntu-22.04
runs-on: ubuntu-22.04
needs:
- get_release_definitions
env:
RELEASE_TAG: ${{needs.get_release_definitions.outputs.RELEASE_TAG}}
continue-on-error: false
steps:
- uses: actions/checkout@v4
with:
filter: "blob:none"
fetch-tags: 'true'
fetch-depth: '1000'
submodules: 'true'
- name: Install Dependencies
if: ${{ github.event.inputs.build_enabled_x86_64 != 'false' }}
run: |
sudo apt update
sudo apt install -y git cmake libsdl2-dev
- name: Configure CMake
if: ${{ github.event.inputs.build_enabled_x86_64 != 'false' }}
run: |
echo "############### configuring cmake"
cmake -B build/ -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSUPPORT_SHADERS=True
- name: Build w/ CMake
if: ${{ github.event.inputs.build_enabled_x86_64 != 'false' }}
run: |
echo "############### building with cmake"
cmake --version
cmake --build build/ --config ${{env.BUILD_TYPE}} --parallel 4
- name: Create Artifact
run: |
mkdir sq68lay-linux-x86_64-Ubuntu-22.04-${{ env.RELEASE_TAG }}/
cp -v build/sqlay3 sq68lay-linux-x86_64-Ubuntu-22.04-${{ env.RELEASE_TAG }}/ ||
touch sq68lay-linux-x86_64-Ubuntu-22.04-${{ env.RELEASE_TAG }}/sqlay3
cp -v build/sq68ux sq68lay-linux-x86_64-Ubuntu-22.04-${{ env.RELEASE_TAG }}/ ||
touch sq68lay-linux-x86_64-Ubuntu-22.04-${{ env.RELEASE_TAG }}/sq68ux
zip -r sq68lay-linux-x86_64-Ubuntu-22.04-${{ env.RELEASE_TAG }}.zip \
sq68lay-linux-x86_64-Ubuntu-22.04-${{ env.RELEASE_TAG }}/
- name: Upload Artifact
uses: actions/upload-artifact@v3
if: github.ref == 'refs/heads/main'
with:
retention-days: 1
name: sq68lay-linux-x86_64-Ubuntu-22.04-${{ env.RELEASE_TAG }}
path: sq68lay-linux-x86_64-Ubuntu-22.04-${{ env.RELEASE_TAG }}.zip
#### Linux ARM
build_arm:
if: ${{ github.event.inputs.job_enabled_arm != 'false' }}
name: Build Linux arm on ${{ matrix.distro }} ${{ matrix.arch }}
runs-on: ubuntu-22.04
needs:
- get_release_definitions
env:
RELEASE_TAG: ${{needs.get_release_definitions.outputs.RELEASE_TAG}}
continue-on-error: false
strategy:
matrix:
include:
- arch: aarch64
arch_source: arm64
distro: ubuntu22.04
distroDescr: ubuntu22.04-jammy
- arch: armv7
arch_source: armhf
distro: ubuntu22.04
distroDescr: ubuntu22.04-jammy
steps:
- uses: actions/checkout@v4
with:
filter: "blob:none"
fetch-tags: 'true'
fetch-depth: '1000'
submodules: 'true'
- uses: uraimo/run-on-arch-action@v2.7.1
if: ${{ github.event.inputs.build_enabled_arm != 'false' }}
name: Build w/ CMake
with:
arch: ${{ matrix.arch }}
distro: ${{ matrix.distro }}
githubToken: ${{ github.token }}
shell: /bin/sh
install: |
case "${{ matrix.distro }}" in
ubuntu*|jessie|stretch|buster|bullseye)
apt-get update -q -y
apt-get install -q -y git libsdl2-dev cmake gcc g++ make
;;
esac
run: |
echo "############### configuring cmake"
cmake -B build/ \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DCMAKE_TOOLCHAIN_FILE=Toolchain-${{ matrix.arch_source }}.cmake
echo "############### building with cmake"
cmake --build build/ --config ${{env.BUILD_TYPE}} --parallel 4
- name: Create Artifact
run: |
mkdir sq68lay-linux-${{ matrix.arch }}-${{ matrix.distroDescr }}-${{ env.RELEASE_TAG }}/
cp -v build/sqlay3 sq68lay-linux-${{ matrix.arch }}-${{ matrix.distroDescr }}-${{ env.RELEASE_TAG }}/ ||
touch sq68lay-linux-${{ matrix.arch }}-${{ matrix.distroDescr }}-${{ env.RELEASE_TAG }}/sqlay3
cp -v build/sq68ux sq68lay-linux-${{ matrix.arch }}-${{ matrix.distroDescr }}-${{ env.RELEASE_TAG }}/ ||
touch sq68lay-linux-${{ matrix.arch }}-${{ matrix.distroDescr }}-${{ env.RELEASE_TAG }}/sq68ux
zip -r sq68lay-linux-${{ matrix.arch }}-${{ matrix.distroDescr }}-${{ env.RELEASE_TAG }}.zip \
sq68lay-linux-${{ matrix.arch }}-${{ matrix.distroDescr }}-${{ env.RELEASE_TAG }}/
- name: Upload Artifact
uses: actions/upload-artifact@v3
if: github.ref == 'refs/heads/main'
with:
retention-days: 1
name: sq68lay-linux-${{ matrix.arch }}-${{ matrix.distroDescr }}-${{ env.RELEASE_TAG }}
path: sq68lay-linux-${{ matrix.arch }}-${{ matrix.distroDescr }}-${{ env.RELEASE_TAG }}*.zip
#### MacOS
build_macos:
if: ${{ github.event.inputs.job_enabled_macos != 'false' }}
name: Build MacOS x86_64 on MacOS-12
runs-on: macos-12
needs:
- get_release_definitions
env:
RELEASE_TAG: ${{needs.get_release_definitions.outputs.RELEASE_TAG}}
continue-on-error: false
steps:
- uses: actions/checkout@v4
with:
filter: "blob:none"
fetch-tags: 'true'
fetch-depth: '1000'
submodules: 'true'
- name: get Arch and O.S. info
run: |
sw_vers
sysctl machdep.cpu.brand_string
- name: Install Dependencies
run: |
brew install sdl2
- name: Configure CMake
if: ${{ github.event.inputs.build_enabled_macos != 'false' }}
run: |
cmake -B build/ -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSUPPORT_SHADERS=True
- name: Build w/ CMake
if: ${{ github.event.inputs.build_enabled_macos != 'false' }}
run: |
cmake --build build/ --config ${{env.BUILD_TYPE}}
- name: Create Artifact
run: |
mkdir sq68lay-macos-intel-${{ env.RELEASE_TAG }}/
cp -v build/sqlay3 sq68lay-macos-intel-${{ env.RELEASE_TAG }}/ ||
touch sq68lay-macos-intel-${{ env.RELEASE_TAG }}/sqlay3
cp -v build/sq68ux sq68lay-macos-intel-${{ env.RELEASE_TAG }}/ ||
touch sq68lay-macos-intel-${{ env.RELEASE_TAG }}/sq68ux
zip -r sq68lay-macos-intel-${{ env.RELEASE_TAG }}.zip \
sq68lay-macos-intel-${{ env.RELEASE_TAG }}/
- name: Upload Artifact
uses: actions/upload-artifact@v3
if: github.ref == 'refs/heads/main'
with:
retention-days: 1
name: sq68lay-macos-intel-${{ env.RELEASE_TAG }}
path: sq68lay-macos-intel-${{ env.RELEASE_TAG }}.zip
#### WINDOWS
build_windows:
if: ${{ github.event.inputs.job_enabled_windows != 'false' }}
name: Build Windows on ${{ matrix.env }} ${{ matrix.sys }}
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
needs:
- get_release_definitions
env:
RELEASE_TAG: ${{needs.get_release_definitions.outputs.RELEASE_TAG}}
continue-on-error: false
strategy:
matrix:
include:
- { sys: mingw64, env: x86_64 }
- { sys: mingw32, env: i686 }
steps:
- uses: actions/checkout@v4
with:
filter: "blob:none"
fetch-tags: 'true'
fetch-depth: '1000'
submodules: 'true'
- uses: msys2/setup-msys2@v2
if: ${{ !github.event.act }}
with:
msystem: ${{matrix.sys}}
update: true
install: >-
git
zip
mingw-w64-${{matrix.env}}-cc
mingw-w64-${{matrix.env}}-SDL2
mingw-w64-${{matrix.env}}-cmake
- name: Configure CMake
if: ${{ github.event.inputs.build_enabled_windows != 'false' }}
run: |
cmake -B build/ -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build w/ CMake
if: ${{ github.event.inputs.build_enabled_windows != 'false' }}
run: |
cmake --build build/ --config ${{env.BUILD_TYPE}}
- name: Create Package
run: |
mkdir sq68lay-windows-${{ matrix.sys }}-${{ env.RELEASE_TAG }}
cp -v build/sqlay3.exe sq68lay-windows-${{ matrix.sys }}-${{ env.RELEASE_TAG }}/ ||
touch sq68lay-windows-${{ matrix.sys }}-${{ env.RELEASE_TAG }}/sqlay3.exe
cp -v build/sq68ux.exe sq68lay-windows-${{ matrix.sys }}-${{ env.RELEASE_TAG }}/ ||
touch sq68lay-windows-${{ matrix.sys }}-${{ env.RELEASE_TAG }}/sq68ux.exe
zip -r sq68lay-windows-${{ matrix.sys }}-${{ env.RELEASE_TAG }}.zip \
sq68lay-windows-${{ matrix.sys }}-${{ env.RELEASE_TAG }}/
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
retention-days: 1
name: sq68lay-windows-${{ matrix.sys }}-${{ env.RELEASE_TAG }}
path: sq68lay-windows-${{ matrix.sys }}-${{ env.RELEASE_TAG }}*.zip
#### Upload artifacts to Releases
upload_artifacts:
name: Upload Artifacts to Releases
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/main'
needs:
# - prepare_artifacts_cache
- get_release_definitions
- build_x86_64
- build_arm
- build_macos
- build_windows
env:
RELEASE_TAG: ${{needs.get_release_definitions.outputs.RELEASE_TAG}}
RELEASE_DESCR: ${{needs.get_release_definitions.outputs.RELEASE_DESCR}}
RELEASE_PRERELEASE: ${{needs.get_release_definitions.outputs.RELEASE_PRERELEASE}}
steps:
- name: Restore Artifacts Cache
uses: actions/download-artifact@v3
with:
path: artifacts
- name: list Artifacts
run: |
ls -la artifacts/*/*
- name: ${{ env.RELEASE_TAG }} ${{ env.RELEASE_DESCR }}
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ env.RELEASE_PRERELEASE}}
tag_name: ${{ env.RELEASE_TAG }}
body_path: artifacts/definitions/RELEASE_LOG.md
files: artifacts/*/*.zip