-
Notifications
You must be signed in to change notification settings - Fork 17
475 lines (396 loc) · 18 KB
/
AutomaticRelease.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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
name: Automatic release
on:
workflow_dispatch:
inputs:
min_game_version:
type: string
description: Minimum game version
required: true
update_timber_api:
type: boolean
description: Update TimberAPI
default: false
required: true
timber_api_update_type:
type: choice
default: beta
description: Update type
required: false
options:
- major
- feature
- bug
- alpha
- beta
- rc
make_active_file_in_modio:
type: boolean
description: Make active file in Mod.io
default: false
required: true
update_timber_api_example:
type: boolean
description: Update TimberAPIExample
required: true
timber_api_example_update_type:
type: choice
default: beta
description: Update type
required: false
options:
- major
- feature
- bug
- alpha
- beta
- rc
env:
#Timber API
timber_api_release_name: "TimberAPI"
timber_api_project_path: "Core/TimberApi/TimberApi.csproj"
timber_api_output_path: "Core/TimberApi/bin/RELEASE/netstandard2.1"
timber_api_nuget_path: "Core/TimberApi/bin/RELEASE"
timber_api_common_project_path: "Core/TimberApi.Common/TimberApi.Common.csproj"
timber_api_common_output_path: "Core/TimberApi.Common/bin/RELEASE/netstandard2.1"
timber_api_common_nuget_path: "Core/TimberApi.Common/bin/RELEASE"
timber_api_core_project_path: "Core/TimberApi.Core/TimberApi.Core.csproj"
timber_api_core_output_path: "Core/TimberApi.Core/bin/RELEASE/netstandard2.1"
timber_api_loaders_project_path: "Loaders/TimberApi.BepInEx.Plugin.Loader"
timber_api_loaders_output_path: "Loaders/TimberApi.BepInEx.Plugin.Loader/bin/RELEASE/netstandard2.1"
timber_api_assets_folder: "Assets"
timber_api_package_folder: "ModIoPackage"
timber_api_package_dll_folder: "ModIoPackage/TimberApi/core"
timber_api_package_assets_folder: "ModIoPackage/TimberApi/core/assets"
#Timber API Example
timber_api_example_release_name: "TimberAPI Example"
timber_api_example_project_path: "Examples/TimberAPIExample.csproj"
timber_api_example_output_path: "Examples/bin/RELEASE/netstandard2.1"
timber_api_example_package_dir: "Examples/ThunderstorePackage"
jobs:
# Automatic updating semantic versioning
versions:
name: Parse project versions
runs-on: ubuntu-latest
outputs:
timber_api: ${{ github.event.inputs.update_timber_api == 'false' && steps.timber_api.outputs.match || steps.bump_timber_api_version.outputs.next-version }}
timber_api_example: ${{ github.event.inputs.update_timber_api_example == 'false' && steps.timber_api_example.outputs.match || steps.bump_timber_api_example_version.outputs.next-version }}
timber_api_leading_zero: ${{ github.event.inputs.update_timber_api == 'false' && steps.timber_api.outputs.match || steps.timber_api_version_finalized.outputs.replaced }}
timber_api_example_leading_zero: ${{ github.event.inputs.update_timber_api_example == 'false' && steps.timber_api_example.outputs.match || steps.timber_api_example_version_finalized.outputs.replaced }}
steps:
- uses: actions/checkout@v3
# Loading versioning file
- name: Read versions.txt
id: read_versions_file
uses: juliangruber/read-file-action@v1
with:
path: ./project_versions.txt
# TimberAPI versioning
- id: timber_api
uses: actions-ecosystem/action-regex-match@v2
with:
text: ${{ steps.read_versions_file.outputs.content }}
regex: '(?<=TIMBER_API=).*'
- id: bump_timber_api_version
uses: christian-draeger/[email protected]
with:
current-version: ${{ steps.timber_api.outputs.match }}
version-fragment: ${{ github.event.inputs.timber_api_update_type }}
- name: Concat string
id: timber_api_version_finalized
uses: greguintow/concat-string-action@v2
with:
string: '0.${{ steps.bump_timber_api_version.outputs.next-version }}'
# TimberAPI Example versioning
- id: timber_api_example
uses: actions-ecosystem/action-regex-match@v2
with:
text: ${{ steps.read_versions_file.outputs.content }}
regex: '(?<=TIMBER_API_EXAMPLE=).*'
- id: bump_timber_api_example_version
uses: christian-draeger/[email protected]
with:
current-version: ${{ steps.timber_api_example.outputs.match }}
version-fragment: ${{ github.event.inputs.timber_api_example_update_type }}
- name: Concat string
id: timber_api_example_version_finalized
uses: greguintow/concat-string-action@v2
with:
string: '0.${{ steps.bump_timber_api_example_version.outputs.next-version }}'
publish_timber_api_nuget:
if: ${{ github.event.inputs.timber_api_update_type == 'major' || github.event.inputs.timber_api_update_type == 'feature' || github.event.inputs.timber_api_update_type == 'bug'}}
runs-on: ubuntu-latest
needs: [versions, create_timber_api_modio_pack]
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
- name: Find and Replace TIMBER_API_VERSION_PLACEHOLDER
uses: jacobtomlinson/gha-find-replace@v2
with:
find: "TIMBER_API_VERSION_PLACEHOLDER"
replace: ${{ needs.versions.outputs.timber_api_leading_zero }}
regex: false
- name: Replace TIMBER_API_EXAMPLE_VERSION
uses: jacobtomlinson/gha-find-replace@v2
with:
find: "TIMBER_API_EXAMPLE_VERSION"
replace: ${{ needs.versions.outputs.timber_api_example_leading_zero }}
regex: false
- name: Restore dependencies
run: dotnet restore
- name: Build TimberAPI.Common
run: dotnet build ${{env.timber_api_common_project_path}} --no-restore --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_leading_zero }}
- name: Build TimberAPI
run: dotnet build ${{env.timber_api_project_path}} --no-restore --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_leading_zero }}
- name: Test
run: dotnet test --no-build --verbosity normal
- name: .NET - Get Project File ReleaseVersion
id: get_version
uses: greenygh0st/net-proj-release-version@v2
with:
PROJ_FILE: ${{env.timber_api_core_project_path}}
- name: Pack TimberAPI.Common
run: dotnet pack ${{env.timber_api_common_project_path}} --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_leading_zero }}
- name: Pack TimberAPI
run: dotnet pack ${{env.timber_api_project_path}} --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_leading_zero }}
- name: Upload TimberAPI.Common Build Artifact
uses: actions/[email protected]
with:
name: TimberAPI.Common_NugetPackage
path: ${{env.timber_api_common_nuget_path}}/*.nupkg
- name: Upload TimberAPI Build Artifact
uses: actions/[email protected]
with:
name: TimberAPI_NugetPackage
path: ${{env.timber_api_nuget_path}}/*.nupkg
- name: Push TimberAPI.Common NuGet Package
if: github.event.inputs.DoPrerelease != 'true'
run: dotnet nuget push ${{env.timber_api_common_nuget_path}}/*.nupkg -k ${{ secrets.TIMBERAPINUGETKEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
- name: Push TimberAPI NuGet Package
if: github.event.inputs.DoPrerelease != 'true'
run: dotnet nuget push ${{env.timber_api_nuget_path}}/*.nupkg -k ${{ secrets.TIMBERAPINUGETKEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
create_timber_api_modio_pack:
if: ${{ github.event.inputs.update_timber_api == 'true' }}
needs: [versions]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
- name: Find and Replace TIMBER_API_VERSION_PLACEHOLDER
uses: jacobtomlinson/gha-find-replace@v2
with:
find: "TIMBER_API_VERSION_PLACEHOLDER"
replace: ${{ needs.versions.outputs.timber_api_leading_zero }}
regex: false
- name: Find and Replace MINIMUN_GAME_VERSION_PLACEHOLDER
uses: jacobtomlinson/gha-find-replace@v2
with:
find: "MINIMUN_GAME_VERSION_PLACEHOLDER"
replace: ${{ github.event.inputs.min_game_version }}
regex: false
- name: Replace TIMBER_API_EXAMPLE_VERSION
uses: jacobtomlinson/gha-find-replace@v2
with:
find: "TIMBER_API_EXAMPLE_VERSION"
replace: ${{ needs.versions.outputs.timber_api_example_leading_zero }}
regex: false
- name: Restore dependencies
run: dotnet restore
- name: Build TimberAPICore
run: dotnet build ${{env.timber_api_core_project_path}} --no-restore --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_leading_zero }};SolutionDir=${{ github.workspace }}
- name: Build Loader
run: dotnet build ${{env.timber_api_loaders_project_path}} --no-restore --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_leading_zero }}
- name: Create TimberAPi folder
run: mkdir ${{ env.timber_api_package_folder }}
- name: Create TimberAPi dll folder
run: mkdir ${{ env.timber_api_package_dll_folder }} -p
- name: Create TimberAPi assets folder
run: mkdir ${{ env.timber_api_package_assets_folder }} -p
- name: Copy TimberApi.Common
run: cp ${{ env.timber_api_core_output_path }}/TimberApi.Common.dll ${{ env.timber_api_package_dll_folder }}
- name: Copy TimberApi.Core
run: cp ${{ env.timber_api_core_output_path }}/TimberApi.Core.dll ${{ env.timber_api_package_dll_folder }}
- name: Copy TimberApi
run: cp ${{ env.timber_api_core_output_path }}/TimberApi.dll ${{ env.timber_api_package_dll_folder }}
- name: Cope TimberApi.BepInEx.Plugin.Loader
run: cp ${{ env.timber_api_loaders_output_path }}/TimberApi.BepInEx.Plugin.Loader.dll ${{ env.timber_api_package_dll_folder }}
- name: Cope asset bundle
run: cp ${{ env.timber_api_assets_folder }}/timber_api ${{ env.timber_api_package_assets_folder }}
#
- name: Upload TimberAPI Mod.io Build Artifact
uses: actions/[email protected]
with:
name: TimberAPI_${{ needs.versions.outputs.timber_api_leading_zero }}
path: ${{ env.timber_api_package_folder }}
- name: Zip Release
uses: TheDoctor0/[email protected]
with:
filename: TimberAPI_${{ needs.versions.outputs.timber_api_leading_zero }}.zip
path: "TimberApi/core"
directory: ${{ env.timber_api_package_folder }}
- name: Read changelog
id: package
uses: juliangruber/read-file-action@v1
with:
path: ./changelog.md
- name: regex match action
id: regex
uses: MeilCli/[email protected]
with:
regex_pattern: '(?<=### Changes\n).*?(?=##)'
regex_option: s
search_string: "${{ steps.package.outputs.content }}"
- name: extract metadata
id: metadata
run: |
GAME_ID=$(jq '.game_id' metadata.json)
MOD_ID=$(jq '.timber_api_mod_id' metadata.json)
echo "GAME=$GAME_ID" >> $GITHUB_OUTPUT
echo "MOD=$MOD_ID" >> $GITHUB_OUTPUT
- uses: nickelc/[email protected]
with:
token: ${{ secrets.MODIO_TOKEN }}
game: ${{ steps.metadata.outputs.GAME }}
mod: ${{ steps.metadata.outputs.MOD }}
version: ${{ needs.versions.outputs.timber_api_leading_zero }}
path: ${{ env.timber_api_package_folder }}/TimberAPI_${{ needs.versions.outputs.timber_api_leading_zero }}.zip
active: ${{ github.event.inputs.make_active_file_in_modio }}
changelog: "${{ steps.regex.outputs.matched_first }}"
create_timber_api_example_modio_pack:
if: ${{ github.event.inputs.update_timber_api_example == 'true' }}
needs: [versions]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
- name: Replace TIMBER_API_VERSION
uses: jacobtomlinson/gha-find-replace@v2
with:
find: "TIMBER_API_VERSION"
replace: ${{ needs.versions.outputs.timber_api_leading_zero }}
regex: false
- name: Replace TIMBER_API_EXAMPLE_VERSION
uses: jacobtomlinson/gha-find-replace@v2
with:
find: "TIMBER_API_EXAMPLE_VERSION"
replace: ${{ needs.versions.outputs.timber_api_example_leading_zero }}
regex: false
- name: Restore dependencies
run: dotnet restore
- name: Build TimberAPIExample
run: dotnet build ${{env.timber_api_example_project_path}} --no-restore --configuration RELEASE -p:Version=${{ needs.versions.outputs.timber_api_example_leading_zero }}
- name: Copy TimberAPIExample.dll to package folder
run: cp ${{ env.timber_api_example_output_path }}/TimberAPIExample.dll ${{ env.timber_api_example_package_dir }}/TimberAPIExample/plugins
- name: Upload TimberAPIExample Mod.io Build Artifact
uses: actions/[email protected]
with:
name: TimberAPIExample_ModioPackage
path: ${{ env.timber_api_example_package_dir }}
update_version:
runs-on: ubuntu-latest
needs: [versions, create_timber_api_modio_pack, create_timber_api_example_modio_pack]
if: always() && (needs.create_timber_api_modio_pack.result == 'success' || needs.create_timber_api_example_modio_pack.result == 'success')
steps:
- uses: actions/checkout@v2
- name: Modify timber api version number
if: needs.create_timber_api_modio_pack.result == 'success'
uses: mingjun97/file-regex-replace@v1
with:
regex: '(?<=TIMBER_API=).*'
replacement: '${{ needs.versions.outputs.timber_api }}'
include: 'project_versions.txt'
- name: Modify changelog
if: needs.create_timber_api_modio_pack.result == 'success'
uses: mingjun97/file-regex-replace@v1
with:
regex: '## Unreleased'
replacement: |
## Unreleased
### Changes
## TimberAPI v${{ needs.versions.outputs.timber_api_leading_zero }}
include: 'changelog.md'
- name: Modify timber api example version number
if: needs.create_timber_api_example_modio_pack.result == 'success'
uses: mingjun97/file-regex-replace@v1
with:
regex: '(?<=TIMBER_API_EXAMPLE=).*'
replacement: '${{ needs.versions.outputs.timber_api_example }}'
include: 'project_versions.txt'
- name: Commit updated version
uses: EndBug/add-and-commit@v9
with:
message: "Updated versions"
default_author: github_actions
create_release:
needs: [versions, publish_timber_api_nuget, create_timber_api_modio_pack, create_timber_api_example_modio_pack, update_version]
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: main
- name: Read changelog
id: package
uses: juliangruber/read-file-action@v1
with:
path: ./changelog.md
- name: Download TimberAPI mod.io artifact
uses: actions/download-artifact@v3
if: needs.create_timber_api_modio_pack.result == 'success'
with:
name: TimberAPI_${{ needs.versions.outputs.timber_api_leading_zero }}
path: ${{ env.timber_api_package_folder }}
- name: Zip Release
uses: TheDoctor0/[email protected]
if: needs.create_timber_api_modio_pack.result == 'success'
with:
filename: TimberAPI_${{ needs.versions.outputs.timber_api_leading_zero }}_modio.zip
path: .
directory: ${{ env.timber_api_package_folder }}
- name: Download TimberAPI NuGet package
uses: actions/download-artifact@v3
if: needs.publish_timber_api_nuget.result == 'success'
with:
name: TimberAPI_NugetPackage
path: .
- name: Download TimberAPI.Common NuGet package
uses: actions/download-artifact@v3
if: needs.publish_timber_api_nuget.result == 'success'
with:
name: TimberAPI.Common_NugetPackage
path: .
- name: Download TimberAPI Exmaple mod.io artifact
uses: actions/download-artifact@v3
if: needs.create_timber_api_example_modio_pack.result == 'success'
with:
name: TimberAPIExample_ModioPackage
path: ${{ env.timber_api_example_package_dir }}
- name: Zip TimberAPI Exmaple
uses: TheDoctor0/[email protected]
if: needs.create_timber_api_example_modio_pack.result == 'success'
with:
filename: TimberAPI_Example_${{ needs.versions.outputs.timber_api_example_leading_zero }}_modio.zip
path: .
directory: ${{ env.timber_api_example_package_dir }}
- name: regex match action
id: regex2
uses: MeilCli/[email protected]
with:
regex_pattern: '## ${{ needs.versions.outputs.timber_api }}.*?(?=## \d)'
regex_option: s
search_string: "${{ steps.package.outputs.content }}"
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.versions.outputs.timber_api_leading_zero }}
name: v${{ needs.versions.outputs.timber_api_leading_zero }}
body: ${{ steps.regex2.outputs.matched_first }}
draft: false
prerelease: false
files: |
**/TimberAPI_${{ needs.versions.outputs.timber_api_leading_zero }}_modio.zip
**/TimberAPI_Example_${{ needs.versions.outputs.timber_api_example_leading_zero }}_modio.zip
**/*.nupkg
token: ${{ secrets.GITHUB_TOKEN }}