-
Notifications
You must be signed in to change notification settings - Fork 0
/
unity-ci.yml
360 lines (348 loc) · 11.5 KB
/
unity-ci.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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
name: "Unity CI 🕹️"
on:
push:
branches: [ "develop", "feat/**" ]
workflow_dispatch:
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
projectPath: 'project'
jobs:
# LICENSE CHECK
licenseCheck:
name: Check for Unity License 📄
runs-on: [ self-hosted, linux, x64 ]
steps:
- name: Fail - No Unity License ☠️
if: ${{ !startsWith(env.UNITY_LICENSE, '<') }}
run: exit 1
# TESTS
testRunner:
needs: licenseCheck
name: Tests (${{ matrix.testMode }}) 🧪
runs-on: [ self-hosted, linux, x64 ]
strategy:
fail-fast: false
matrix:
testMode:
- PlayMode
- EditMode
steps:
# checkout
- name: Checkout Repository
uses: actions/checkout@v3
with:
lfs: true
# cache
- name: Restore Library Cache
uses: actions/cache@v3
with:
path: ${{ env.projectPath }}/Library
key: Library-${{ env.projectPath }}
restore-keys: Library-
# tests
- name: Run ${{ matrix.testMode }} Tests
uses: game-ci/unity-test-runner@v2
id: testRunner
with:
projectPath: ${{ env.projectPath }}
testMode: ${{ matrix.testMode }}
artifactsPath: ${{ matrix.testMode }}-artifacts
githubToken: ${{ secrets.GITHUB_TOKEN }}
gitPrivateToken: ${{ secrets.GIT_PRIVATE_TOKEN }}
checkName: ${{ matrix.testMode }} Test Results
# test results
- name: Test Results - ${{ matrix.testMode }}
uses: actions/upload-artifact@v3
if: always()
with:
name: Test Results (${{ matrix.testMode }})
path: ${{ steps.testRunner.outputs.artifactsPath }}
# code coverage
- name: Coverage Report - ${{ matrix.testMode }}
uses: actions/upload-artifact@v3
if: always()
with:
name: Coverage Results (${{ matrix.testMode }})
path: ${{ steps.testRunner.outputs.coveragePath }}
# TAG CHECK
tagCheck:
needs: testRunner
name: Is Commit a Release 🔖
runs-on: [ self-hosted, linux, x64 ]
outputs:
release: ${{ steps.check.outputs.release }}
tagname: ${{ steps.check.outputs.tagname }}
steps:
- name: Check Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setting Release Variable
id: check
run: |
githash=$(git rev-parse --short "$GITHUB_SHA")
tagname=$(git tag --contains $githash)
if [ -n "$tagname" ]; then
printf "githash: %s\nrelease: true\ntagname: %s\n" "$githash" "$tagname"
echo "release=true" >> "$GITHUB_OUTPUT"
echo "tagname=$tagname" >> "$GITHUB_OUTPUT"
else
printf "githash: %s\nrelease: false\ntagname: %s\n" "$githash" "$tagname"
echo "release=false" >> "$GITHUB_OUTPUT"
echo "tagname=$tagname" >> "$GITHUB_OUTPUT"
fi
# CODECOV/TEST RESULTS => TESTS REPO
testResults:
needs: testRunner
name: Push Test Results 🚚
runs-on: [ self-hosted, linux, x64 ]
strategy:
fail-fast: false
steps:
# checkout
- name: Checkout Repository
uses: actions/checkout@v3
# download test artifacts
- name: Download All Artifacts
uses: actions/download-artifact@v3
with:
path: build/artifacts
# get current date
- name: Get Current Date
id: date
run: echo "date=$(date +'%Y%m%d')" >> "$GITHUB_OUTPUT"
# get curent git hash
- name: Get Current Date
id: hash
run: echo "githash=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_OUTPUT"
# push to tests repo
- name: Push to Tests Repository
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.ABC_REPO_TOKEN }}
with:
source-directory: 'build/artifacts/'
destination-github-username: 'kyaulabs'
destination-repository-name: 'abc-tests'
user-name: 'kyaulabs-bot'
user-email: [email protected]
create-target-branch-if-needed: true
target-branch: main
target-directory: 'tests-${{ steps.date.outputs.date }}-${{ steps.hash.outputs.githash }}'
# BUILD: WINDOWS
buildWindows:
needs: tagCheck
if: ${{ needs.tagCheck.outputs.release == 'true' }}
name: Build Windows Client 💾
runs-on: [ self-hosted, linux, x64 ]
strategy:
fail-fast: false
matrix:
targetPlatform:
- StandaloneWindows64
steps:
# checkout
- name: Check Repository
uses: actions/checkout@v3
with:
lfs: true
# cache
- name: Restore Library Cache
uses: actions/cache@v3
with:
path: ${{ env.projectPath }}/Library
key: Library-${{ env.projectPath }}-Win64
restore-keys: Library-
# build
- name: Build Win64 Client
uses: game-ci/unity-builder@v2
with:
gitPrivateToken: ${{ secrets.GIT_PRIVATE_TOKEN }}
projectPath: ${{ env.projectPath }}
targetPlatform: ${{ matrix.targetPlatform }}
versioning: Semantic
# client download
- name: Windows Client
uses: actions/upload-artifact@v3
with:
name: Client-Win64
path: build/StandaloneWindows64
# BUILD: LINUX
buildLinux:
needs: tagCheck
if: ${{ needs.tagCheck.outputs.release == 'true' }}
name: Build Linux Client 💾
runs-on: [ self-hosted, linux, x64 ]
strategy:
fail-fast: false
matrix:
targetPlatform:
- StandaloneLinux64
steps:
# checkout
- name: Check Repository
uses: actions/checkout@v3
with:
lfs: true
# cache
- name: Restore Library Cache
uses: actions/cache@v3
with:
path: ${{ env.projectPath }}/Library
key: Library-${{ env.projectPath }}-Linux64
restore-keys: Library-
# build
- name: Build Linux64 Client
uses: game-ci/unity-builder@v2
with:
gitPrivateToken: ${{ secrets.GIT_PRIVATE_TOKEN }}
projectPath: ${{ env.projectPath }}
targetPlatform: ${{ matrix.targetPlatform }}
versioning: Semantic
# client download
- name: Linux Client
uses: actions/upload-artifact@v3
with:
name: Client-Linux64
path: build/StandaloneLinux64
# BUILD: MACOSX
buildOSX:
needs: tagCheck
if: ${{ needs.tagCheck.outputs.release == 'true' }}
name: Build MacOSX Client 💾
runs-on: [ self-hosted, linux, x64 ]
strategy:
fail-fast: false
matrix:
targetPlatform:
- StandaloneOSX
steps:
# checkout
- name: Check Repository
uses: actions/checkout@v3
with:
lfs: true
# cache
- name: Restore Library Cache
uses: actions/cache@v3
with:
path: ${{ env.projectPath }}/Library
key: Library-${{ env.projectPath }}-MacOSX
restore-keys: Library-
# build
- name: Build MacOSX Client
uses: game-ci/unity-builder@v2
with:
gitPrivateToken: ${{ secrets.GIT_PRIVATE_TOKEN }}
projectPath: ${{ env.projectPath }}
targetPlatform: ${{ matrix.targetPlatform }}
versioning: Semantic
# client download
- name: Mac Client
uses: actions/upload-artifact@v3
with:
name: Client-MacOSX
path: build/StandaloneOSX
# BUILD: WEBGL
buildWebGL:
if: false
needs: tagCheck
#if: ${{ needs.tagCheck.outputs.release == 'true' }}
name: Build WebGL Client 💾
runs-on: [ self-hosted, linux, x64 ]
strategy:
fail-fast: false
matrix:
targetPlatform:
- WebGL
steps:
# checkout
- name: Check Repository
uses: actions/checkout@v3
with:
lfs: true
# cache
- name: Restore Library Cache
uses: actions/cache@v3
with:
path: ${{ env.projectPath }}/Library
key: Library-${{ env.projectPath }}-WebGL
restore-keys: Library-
# build
- name: Build WebGL Client
uses: game-ci/unity-builder@v2
with:
gitPrivateToken: ${{ secrets.GIT_PRIVATE_TOKEN }}
projectPath: ${{ env.projectPath }}
targetPlatform: ${{ matrix.targetPlatform }}
versioning: Semantic
# client download
- name: WebGL Client
uses: actions/upload-artifact@v3
with:
name: Client-WebGL
path: build/WebGL
# DEPLOY PAGES
deployPages:
needs: buildWebGL
name: Deploy to GitHub Pages 🚀
runs-on: [ self-hosted, linux, x64 ]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Download WebGL Artifacts
uses: actions/download-artifact@v3
with:
name: build-WebGL
path: build
- name: Display File structure
run: ls -R
working-directory: build/WebGL
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: build/WebGL
# RELEASE
publicRelease:
needs: [tagCheck, buildWindows, buildLinux, buildOSX]
name: Release 🔖
runs-on: [ self-hosted, linux, x64 ]
strategy:
fail-fast: false
env:
tagname: ${{ needs.tagCheck.outputs.tagname }}
steps:
# checkout
- name: Checkout Repository
uses: actions/checkout@v3
# download build artifacts
- name: Download All Artifacts
uses: actions/download-artifact@v3
with:
path: build/artifacts
# compress clients
- name: List Directory
run: ls -FalG build/artifacts/Client-Win64/
- name: Compress Windows Client
run: 7z a -tzip -y -mx=9 build/${{ env.projectPath }}-client-win64-${{ needs.tagCheck.outputs.tagname }}.zip build/artifacts/Client-Win64
- name: Generate Windows Client SHA512
run: sha512sum build/${{ env.projectPath }}-client-win64-${{ needs.tagCheck.outputs.tagname }}.zip > build/${{ env.projectPath }}-client-win64-${{ needs.tagCheck.outputs.tagname }}.zip.sha512
- name: Compress Linux Client
run: tar -I 'zstd' -cvf build/${{ env.projectPath }}-client-linux64-${{ needs.tagCheck.outputs.tagname }}.tar.zst build/artifacts/Client-Linux64
- name: Generate Linux Client SHA512
run: sha512sum build/${{ env.projectPath }}-client-linux64-${{ needs.tagCheck.outputs.tagname }}.tar.zst > build/${{ env.projectPath }}-client-linux64-${{ needs.tagCheck.outputs.tagname }}.tar.zst.sha512
- name: Compress MacOSX Client
run: 7z a -tzip -y -mx=9 build/${{ env.projectPath }}-client-macosx-${{ needs.tagCheck.outputs.tagname }}.zip build/artifacts/Client-MacOSX
- name: Generate MacOSX Client SHA512
run: sha512sum build/${{ env.projectPath }}-client-macosx-${{ needs.tagCheck.outputs.tagname }}.zip > build/${{ env.projectPath }}-client-macosx-${{ needs.tagCheck.outputs.tagname }}.zip.sha512
# generate changelog
- name: Generate UPDATE.md
run: git-cliff --current > build/UPDATE.md
# new release
- uses: ncipollo/release-action@v1
with:
artifacts: build/${{ env.projectPath }}-client-*-${{ needs.tagCheck.outputs.tagname }}.*
bodyFile: build/UPDATE.md
tag: ${{ needs.tagCheck.outputs.tagname }}
token: ${{ secrets.BOT_TOKEN }}