-
Notifications
You must be signed in to change notification settings - Fork 363
416 lines (355 loc) · 14.2 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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
name: Intersect (main)
on:
push:
branches: [ "main" ]
paths-ignore:
- '.github/**'
- 'Documentation/**'
- '.gitignore'
- '*.DotSettings'
- '*.json'
- '*.md'
workflow_dispatch:
inputs:
forceBuild:
description: 'If the build should be forced even on cache hit'
default: false
type: boolean
forceRestore:
description: 'If dependencies should be forced even on cache hit'
default: false
type: boolean
workflowDebug:
description: 'If the workflow should be debugged (skips packaging and publishing)'
default: true
type: boolean
packagingDebug:
description: 'If the packaging step should be debugged (skips publishing)'
default: true
type: boolean
skipForumPublish:
description: 'If publishing to the forum should be skipped'
default: true
type: boolean
permissions:
contents: write
env:
VERSION_PREFIX: 0.8.0
VERSION_SUFFIX: -beta
jobs:
generate-keys:
name: Generate Version-Specific Network Keys
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache binaries
uses: actions/cache@v3
id: cache-binaries
with:
key: ${{ runner.os }}-binaries-keys-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/**/*.cs*') }}
path: |
Intersect*/bin/Release/**/*
- name: Setup dotnet
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Cache NuGet dependencies
uses: actions/cache@v3
id: cache-nuget
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
with:
key: ${{ runner.os }}-nuget-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/*.csproj') }}
path: |
~/.nuget/packages
Intersect*/obj/
- name: Apply environment patches
run: git apply disable-windows-editor.patch
- name: Restore NuGet Packages
if: steps.cache-binaries.outputs.cache-hit != 'true' && steps.cache-nuget.outputs.cache-hit != 'true' || inputs.forceRestore == true
run: dotnet restore Intersect.sln
- name: Build Intersect.Network
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
run: dotnet build Intersect.Network/Intersect.Network.csproj --sc -r linux-x64 -p:Configuration=Release -p:PackageVersion=${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }} -p:Version=${{ env.VERSION_PREFIX }}.${{ github.run_number }}
- name: Debug files on disk
if: inputs.workflowDebug == true
run: ls -laR .
- name: Upload keys
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: keys
path: ./Intersect.Network/bin/Release/keys/*
build-linux:
name: Build for Linux
needs: [generate-keys]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache binaries
uses: actions/cache@v3
id: cache-binaries
with:
key: ${{ runner.os }}-binaries-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/**/*.cs*') }}
path: |
Intersect*/bin/Release/**/*
- name: Setup dotnet
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Cache NuGet dependencies
uses: actions/cache@v3
id: cache-nuget
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
with:
key: ${{ runner.os }}-nuget-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/*.csproj') }}
path: |
~/.nuget/packages
Intersect*/obj/
- name: Apply environment patches
run: git apply disable-windows-editor.patch
- name: Restore NuGet Packages
if: steps.cache-binaries.outputs.cache-hit != 'true' && steps.cache-nuget.outputs.cache-hit != 'true' || inputs.forceRestore == true
run: dotnet restore Intersect.sln
- name: Download keys
uses: actions/download-artifact@v3
with:
name: keys
path: ./Intersect.Network/bin/Release/keys/
- name: Debug keys
run: ls -laR ./Intersect.Network/bin/Release/keys
- name: Build solution
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
run: dotnet publish Intersect.sln --sc -r linux-x64 -p:Configuration=Release -p:PackageVersion=${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }} -p:Version=${{ env.VERSION_PREFIX }}.${{ github.run_number }}
- name: Tarball artifacts to maintain unix file permissions
run: tar -cvf linux.tar Intersect.Client/bin/Release/*/*/publish Intersect.Server/bin/Release/*/*/publish
- name: Debug files on disk
if: inputs.workflowDebug == true
run: ls -laR .
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: engine
path: linux.tar
build-macos:
name: Build for MacOS
needs: [generate-keys]
runs-on: macos-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache binaries
uses: actions/cache@v3
id: cache-binaries
with:
key: ${{ runner.os }}-binaries-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/**/*.cs*') }}
path: |
Intersect*/bin/Release/**/*
- name: Setup dotnet
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Cache NuGet dependencies
uses: actions/cache@v3
id: cache-nuget
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
with:
key: ${{ runner.os }}-nuget-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/*.csproj') }}
path: |
~/.nuget/packages
Intersect*/obj/
- name: Apply environment patches
run: git apply disable-windows-editor.patch
- name: Restore NuGet Packages
if: steps.cache-binaries.outputs.cache-hit != 'true' && steps.cache-nuget.outputs.cache-hit != 'true' || inputs.forceRestore == true
run: dotnet restore Intersect.sln
- name: Download keys
uses: actions/download-artifact@v3
with:
name: keys
path: ./Intersect.Network/bin/Release/keys/
- name: Debug keys
run: ls -laR ./Intersect.Network/bin/Release/keys
- name: Build solution
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
run: dotnet publish Intersect.sln --sc -r osx-x64 -p:Configuration=Release -p:PackageVersion=${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }} -p:Version=${{ env.VERSION_PREFIX }}.${{ github.run_number }}
- name: Tarball artifacts to maintain unix file permissions
run: tar -cvf osx.tar Intersect.Client/bin/Release/*/*/publish Intersect.Server/bin/Release/*/*/publish
- name: Debug files on disk
if: inputs.workflowDebug == true
run: ls -laR .
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: engine
path: osx.tar
build-windows:
name: Build for Windows
needs: [generate-keys]
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache binaries
uses: actions/cache@v3
id: cache-binaries
with:
key: ${{ runner.os }}-binaries-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/**/*.cs*') }}
path: |
Intersect*/bin/Release/**/*
- name: Setup dotnet
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Cache NuGet dependencies
uses: actions/cache@v3
id: cache-nuget
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
with:
key: ${{ runner.os }}-nuget-${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}-${{ hashFiles('Intersect*/*.csproj') }}
path: |
~/.nuget/packages
Intersect*/obj/
- name: Apply environment patches
run: echo "No patches to apply for Windows"
- name: Restore NuGet Packages
if: steps.cache-binaries.outputs.cache-hit != 'true' && steps.cache-nuget.outputs.cache-hit != 'true' || inputs.forceRestore == true
run: dotnet restore Intersect.sln
- name: Download keys
uses: actions/download-artifact@v3
with:
name: keys
path: ./Intersect.Network/bin/Release/keys/
- name: Debug keys
run: ls -laR ./Intersect.Network/bin/Release/keys
shell: bash
- name: Build solution
if: steps.cache-binaries.outputs.cache-hit != 'true' || inputs.forceBuild == true || inputs.forceRestore == true
run: dotnet publish Intersect.sln --sc -r win-x64 -p:Configuration=Release -p:PackageVersion=${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }} -p:Version=${{ env.VERSION_PREFIX }}.${{ github.run_number }}
- name: Tarball artifacts to maintain unix file permissions
run: tar -cvf win.tar Intersect.Client/bin/Release/*/*/publish Intersect.Editor/bin/Release/*/*/publish Intersect.Server/bin/Release/*/*/publish
shell: bash
- name: Debug files on disk
if: inputs.workflowDebug == true
run: ls -laR .
shell: bash
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: engine
path: win.tar
debug-build-artifacts:
name: Debug Build Artifacts
if: inputs.workflowDebug == true
needs: [build-linux, build-macos, build-windows]
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: engine
path: .
- name: Extract build archives
run: |
tar -xvf linux.tar
tar -xvf osx.tar
tar -xvf win.tar
- name: Debug output
run: ls -laR .
publish-github:
name: Publish GitHub Release
if: inputs.workflowDebug != true
needs: [build-linux, build-macos, build-windows]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: engine
path: .
- name: Extract build archives
run: |
tar -xvf linux.tar
tar -xvf osx.tar
tar -xvf win.tar
- name: Checkout assets main_upgrade branch
uses: actions/checkout@v4
with:
fetch-depth: 0
path: assets_upgrade
repository: AscensionGameDev/Intersect-Assets
ref: main_upgrade
token: ${{ secrets.INTERSECTBOT_ACCESS_TOKEN }}
- name: Checkout target main_full branch
uses: actions/checkout@v4
with:
fetch-depth: 0
path: assets_full
repository: AscensionGameDev/Intersect-Assets
ref: main_full
token: ${{ secrets.INTERSECTBOT_ACCESS_TOKEN }}
- name: Package artifacts
uses: AscensionGameDev/actions@cc2eb0e356546042e4dc7eca6788fd0b5a063b32
with:
bundle: .github/bundles/*.json
version: ${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}+build.${{ github.sha }}
- name: Debug packaging output
if: inputs.packagingDebug == true
run: ls -laR ./dist
- name: Publish GitHub Release
if: inputs.packagingDebug != true
uses: ncipollo/[email protected]
with:
artifacts: "dist/**/*.zip"
commit: ${{ github.sha }}
generateReleaseNotes: true
name: ${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}
prerelease: true
tag: v${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}.${{ github.run_number }}
check-publish-forum:
name: Check if token set to publish to forum
if: inputs.workflowDebug != true && inputs.packagingDebug != true && inputs.skipForumPublish != true
needs: publish-github
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check-INTERSECTBOT_FORUM_TOKEN.outputs.skip == 'true' }}
steps:
- id: check-INTERSECTBOT_FORUM_TOKEN
name: Check INTERSECTBOT_FORUM_TOKEN
env:
INTERSECTBOT_FORUM_TOKEN: ${{ secrets.INTERSECTBOT_FORUM_TOKEN }}
if: ${{ env.INTERSECTBOT_FORUM_TOKEN == '' }}
run: echo "skip=true" >> "$GITHUB_OUTPUT"
publish-forum:
name: Publish to Forum
if: inputs.workflowDebug != true && inputs.packagingDebug != true && inputs.skipForumPublish != true && needs.check-publish-forum.outputs.skip != 'true'
needs: check-publish-forum
runs-on: ubuntu-latest
steps:
- name: Publish to Forum
uses: AscensionGameDev/actions@0223df40becb110039c705c02cfd2cd8f274199c
with:
api-key: ${{ secrets.INTERSECTBOT_FORUM_TOKEN }}
build: ${{ github.run_number }}
hash: ${{ github.sha }}
runtime-identifiers: linux-x64,osx-x64,win-x64
topic-id: ${{ vars.INTERSECTBOT_FORUM_TOPIC_ID }}
version: ${{ env.VERSION_PREFIX }}${{ env.VERSION_SUFFIX }}