-
Notifications
You must be signed in to change notification settings - Fork 7
658 lines (561 loc) · 20.7 KB
/
Copy pathpublish.yml
File metadata and controls
658 lines (561 loc) · 20.7 KB
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
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
name: Publish
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
NUGET_OUTPUT: ./Artifacts/NuGet
DOTNET8_VERSION: "8.0.410"
DOTNET9_VERSION: "9.0.x"
DOTNET_VERSION: "10.0.x"
DOTNET_X64_CACHE: "dotnet-x64-cache-${{ github.sha }}"
DOTNET_ARM64_CACHE: "dotnet-arm64-cache-${{ github.sha }}"
WORKBENCH_CACHE: "web-cache-${{ github.sha }}"
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release'
required: true
default: '0.0.0'
type: string
release-notes:
description: 'Release notes'
required: true
default: 'No release notes'
type: string
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
pull_request:
types: [closed]
branches:
- "**"
paths:
- "Source/**"
permissions:
contents: write
deployments: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.release.outputs.version }}
publish: ${{ steps.release.outputs.should-publish }}
prerelease: ${{ steps.release.outputs.prerelease }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Release
id: release
uses: cratis/release-action@v1
with:
version: ${{ github.event.inputs.version }}
release-notes: ${{ github.event.inputs.release-notes }}
generate-protos:
if: needs.release.outputs.publish == 'true'
needs: [release]
uses: ./.github/workflows/generate-protos.yml
coverage-statistics:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [release]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_WORKFLOWS }}
- name: Restore cached coverage
uses: actions/cache@v4
with:
path: ./coverage-reports
key: coverage-cache-${{ github.sha }}
fail-on-cache-miss: false
- name: Collect coverage statistics for release
run: |
.github/scripts/collect-coverage.sh \
"./coverage-reports" \
"./Documentation/statistics/coverage-data.js" \
"${{ needs.release.outputs.version }}" \
"${{ github.sha }}" \
"${{ github.event.head_commit.message }}"
- name: Commit coverage statistics
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add Documentation/statistics/coverage-data.js
if git diff --staged --quiet; then
echo "No coverage statistics changes to commit"
else
git commit -m "Update coverage statistics for release ${{ needs.release.outputs.version }} [skip ci]"
git pull --rebase origin ${{ github.ref_name }}
git push
fi
benchmark-results:
if: needs.release.outputs.publish == 'true' && github.event.pull_request.merged == true
runs-on: ubuntu-latest
needs: [release]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_WORKFLOWS }}
- name: Restore cached benchmark results
uses: actions/cache@v4
with:
path: Documentation/benchmarks/benchmark-data.json
key: benchmark-cache-${{ github.sha }}
fail-on-cache-miss: false
- name: Check if benchmark data exists
id: check-benchmark
run: |
if [ -f "Documentation/benchmarks/benchmark-data.json" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "No cached benchmark data found for commit ${{ github.sha }}, skipping"
fi
- name: Commit benchmark results
if: steps.check-benchmark.outputs.exists == 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add Documentation/benchmarks/
if git diff --staged --quiet; then
echo "No benchmark result changes to commit"
else
git commit -m "Update benchmark results for release ${{ needs.release.outputs.version }} [skip ci]"
git pull --rebase origin ${{ github.ref_name }}
git push
fi
dotnet-x64:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .Net
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{ env.DOTNET8_VERSION }}
${{ env.DOTNET9_VERSION }}
${{ env.DOTNET_VERSION }}
- uses: actions/cache@v3
id: dotnet-x64-output
with:
path: ./Source/Kernel/Server/out/x64
key: ${{ env.DOTNET_X64_CACHE }}
- name: Build x64 Kernel - self contained, ready to run
working-directory: ./Source/Kernel/Server
run: |
dotnet publish -c Release -f net10.0 -r linux-x64 -p:PublishReadyToRun=true -p:DisableProxyGenerator=true -p:Version=${{ needs.release.outputs.version }} -p:SourceRevisionId=${{ github.sha }} --self-contained -o out/x64
dotnet-arm64:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-24.04-arm
needs: [release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .Net
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{ env.DOTNET8_VERSION }}
${{ env.DOTNET9_VERSION }}
${{ env.DOTNET_VERSION }}
- uses: actions/cache@v3
id: dotnet-arm64-output
with:
path: ./Source/Kernel/Server/out/arm64
key: ${{ env.DOTNET_ARM64_CACHE }}
- name: Build arm64 Kernel - self contained, ready to run
working-directory: ./Source/Kernel/Server
run: |
dotnet publish -c Release -f net10.0 -r linux-arm64 -p:PublishReadyToRun=true -p:DisableProxyGenerator=true -p:Version=${{ needs.release.outputs.version }} -p:SourceRevisionId=${{ github.sha }} --self-contained -o out/arm64
workbench:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
id: workbench-output
with:
path: ./Source/Workbench/wwwroot
key: ${{ env.WORKBENCH_CACHE }}
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: "https://registry.npmjs.org"
- uses: actions/cache@v3
id: yarn-cache
with:
path: |
.yarn/cache
**/node_modules
**/.eslintcache
**/yarn.lock
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
- name: Yarn install
working-directory: ./Source/Workbench
run: yarn install
- name: Build Workbench
working-directory: ./Source/Workbench
run: |
yarn build
env:
CHRONICLE_VERSION: ${{ needs.release.outputs.version }}
CHRONICLE_COMMIT_SHA: ${{ github.sha }}
dotnet-pack-and-publish:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [release, dotnet-x64, dotnet-arm64, workbench, dotnet-x64-development, dotnet-arm64-development]
permissions:
# Required for NuGet trusted publishing using OIDC tokens
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
id: workbench-output
with:
path: ./Source/Workbench/wwwroot
key: ${{ env.WORKBENCH_CACHE }}
- name: Setup .Net
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{ env.DOTNET8_VERSION }}
${{ env.DOTNET9_VERSION }}
${{ env.DOTNET_VERSION }}
- name: Remove any existing artifacts
run: rm -rf ${{ env.NUGET_OUTPUT }}
- name: Build and Create NuGet packages
run: |
for project in $(find ./Source/Clients -name "*.csproj" ! -name "*.Specs.csproj"); do
dotnet pack "$project" --configuration Release -o ${{ env.NUGET_OUTPUT }} -p:IsPackaging=true -p:Version=${{ needs.release.outputs.version }} -p:PackageVersion=${{ needs.release.outputs.version }} -p:SourceRevisionId=${{ github.sha }}
done
# Also pack the Contracts project from Kernel
dotnet pack ./Source/Kernel/Contracts/Contracts.csproj --configuration Release -o ${{ env.NUGET_OUTPUT }} -p:IsPackaging=true -p:Version=${{ needs.release.outputs.version }} -p:PackageVersion=${{ needs.release.outputs.version }} -p:SourceRevisionId=${{ github.sha }}
# Get a short-lived NuGet API key
- name: NuGet login (OIDC → temp API key)
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USER }}
- name: Push NuGet packages
run: dotnet nuget push --skip-duplicate '${{ env.NUGET_OUTPUT }}/*.nupkg' --timeout 900 --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json
publish-typescript-client:
if: needs.release.outputs.publish == 'true'
needs: [release, generate-protos]
uses: ./.github/workflows/publish-typescript-client.yml
secrets: inherit
with:
version: ${{ needs.release.outputs.version }}
protos-artifact: proto-files
publish-kotlin-client:
if: needs.release.outputs.publish == 'true'
needs: [release, generate-protos]
uses: ./.github/workflows/publish-kotlin-client.yml
secrets: inherit
with:
version: ${{ needs.release.outputs.version }}
protos-artifact: proto-files
publish-elixir-client:
if: needs.release.outputs.publish == 'true'
needs: [release, generate-protos]
uses: ./.github/workflows/publish-elixir-client.yml
secrets: inherit
with:
version: ${{ needs.release.outputs.version }}
protos-artifact: proto-files
dotnet-x64-development:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .Net
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{ env.DOTNET8_VERSION }}
${{ env.DOTNET9_VERSION }}
${{ env.DOTNET_VERSION }}
- uses: actions/cache@v3
id: dotnet-x64-development-output
with:
path: ./Source/Kernel/Server/out/x64
key: ${{ env.DOTNET_X64_CACHE }}-development
- name: Build development x64 Kernel (DEVELOPMENT symbol)
working-directory: ./Source/Kernel/Server
run: |
dotnet publish -c Debug -f net10.0 -r linux-x64 -p:DefineConstants=DEVELOPMENT -p:Version=${{ needs.release.outputs.version }} -p:SourceRevisionId=${{ github.sha }} -o out/x64
dotnet-arm64-development:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-24.04-arm
needs: [release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .Net
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{ env.DOTNET8_VERSION }}
${{ env.DOTNET9_VERSION }}
${{ env.DOTNET_VERSION }}
- uses: actions/cache@v3
id: dotnet-arm64-development-output
with:
path: ./Source/Kernel/Server/out/arm64
key: ${{ env.DOTNET_ARM64_CACHE }}-development
- name: Build development arm64 Kernel (DEVELOPMENT symbol)
working-directory: ./Source/Kernel/Server
run: |
dotnet publish -c Debug -f net10.0 -r linux-arm64 -p:DefineConstants=DEVELOPMENT -p:Version=${{ needs.release.outputs.version }} -p:SourceRevisionId=${{ github.sha }} -o out/arm64
publish-docker-production:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [release, dotnet-x64, dotnet-arm64, workbench, dotnet-x64-development, dotnet-arm64-development]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
id: dotnet-x64-output
with:
path: ./Source/Kernel/Server/out/x64
key: ${{ env.DOTNET_X64_CACHE }}
fail-on-cache-miss: true
- uses: actions/cache@v3
id: dotnet-arm64-output
with:
path: ./Source/Kernel/Server/out/arm64
key: ${{ env.DOTNET_ARM64_CACHE }}
- uses: actions/cache@v3
id: workbench-output
with:
path: ./Source/Workbench/wwwroot
key: ${{ env.WORKBENCH_CACHE }}
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Prepare Docker tags
id: docker-tags
run: |
TAGS="cratis/chronicle:${{ needs.release.outputs.version }}"
if [ "${{ needs.release.outputs.prerelease }}" != "true" ]; then
TAGS="${TAGS}\ncratis/chronicle:latest"
fi
echo "tags<<EOF" >> $GITHUB_OUTPUT
echo -e "$TAGS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Build Production Docker Image
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Docker/Production/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker-tags.outputs.tags }}
build-args: |
VERSION=${{ needs.release.outputs.version }}
publish-docker-workbench:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [release, dotnet-x64, dotnet-arm64, workbench, dotnet-x64-development, dotnet-arm64-development]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
id: workbench-output
with:
path: ./Source/Workbench/wwwroot
key: ${{ env.WORKBENCH_CACHE }}
fail-on-cache-miss: true
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Prepare Docker tags
id: docker-tags
run: |
TAGS="cratis/chronicle:${{ needs.release.outputs.version }}-workbench"
if [ "${{ needs.release.outputs.prerelease }}" != "true" ]; then
TAGS="${TAGS}\ncratis/chronicle:latest-workbench"
fi
echo "tags<<EOF" >> $GITHUB_OUTPUT
echo -e "$TAGS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Build Workbench Image
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Docker/Workbench/Dockerfile
push: true
tags: ${{ steps.docker-tags.outputs.tags }}
build-args: |
VERSION=${{ needs.release.outputs.version }}
publish-docker-development:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [release, dotnet-x64, dotnet-arm64, workbench, dotnet-x64-development, dotnet-arm64-development]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
id: dotnet-x64-development-output
with:
path: ./Source/Kernel/Server/out/x64
key: ${{ env.DOTNET_X64_CACHE }}-development
fail-on-cache-miss: true
- uses: actions/cache@v3
id: dotnet-arm64-development-output
with:
path: ./Source/Kernel/Server/out/arm64
key: ${{ env.DOTNET_ARM64_CACHE }}-development
fail-on-cache-miss: true
- uses: actions/cache@v3
id: workbench-output
with:
path: ./Source/Workbench/wwwroot
key: ${{ env.WORKBENCH_CACHE }}
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Prepare Docker tags
id: docker-tags
run: |
TAGS="cratis/chronicle:${{ needs.release.outputs.version }}-development"
if [ "${{ needs.release.outputs.prerelease }}" != "true" ]; then
TAGS="${TAGS}\ncratis/chronicle:latest-development"
fi
echo "tags<<EOF" >> $GITHUB_OUTPUT
echo -e "$TAGS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Build Development Docker Image
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Docker/Development/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker-tags.outputs.tags }}
build-args: |
VERSION=${{ needs.release.outputs.version }}
- name: Trigger Documentation Build
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT_DOCUMENTATION }}
repository: cratis/documentation
event-type: build-docs
- name: Trigger Dependency Updates on Sample Repository
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT_DOCUMENTATION }}
repository: cratis/samples
event-type: update-dependencies
publish-docker-development-slim:
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
needs: [release, dotnet-x64, dotnet-arm64, workbench, dotnet-x64-development, dotnet-arm64-development]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v3
id: dotnet-x64-development-output
with:
path: ./Source/Kernel/Server/out/x64
key: ${{ env.DOTNET_X64_CACHE }}-development
fail-on-cache-miss: true
- uses: actions/cache@v3
id: dotnet-arm64-development-output
with:
path: ./Source/Kernel/Server/out/arm64
key: ${{ env.DOTNET_ARM64_CACHE }}-development
fail-on-cache-miss: true
- uses: actions/cache@v3
id: workbench-output
with:
path: ./Source/Workbench/wwwroot
key: ${{ env.WORKBENCH_CACHE }}
fail-on-cache-miss: true
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Prepare Docker tags
id: docker-tags
run: |
TAGS="cratis/chronicle:${{ needs.release.outputs.version }}-development-slim"
if [ "${{ needs.release.outputs.prerelease }}" != "true" ]; then
TAGS="${TAGS}\ncratis/chronicle:latest-development-slim"
fi
echo "tags<<EOF" >> $GITHUB_OUTPUT
echo -e "$TAGS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Build Development Slim Docker Image
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Docker/DevelopmentSlim/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker-tags.outputs.tags }}
build-args: |
VERSION=${{ needs.release.outputs.version }}