Repository navigation
752 lines (648 loc) · 26.8 KB
/
Copy pathcontainer-images.yml
File metadata and controls
752 lines (648 loc) · 26.8 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
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
name: Container Images - Build, Sign & Publish (v2.0)
on:
push:
branches:
- main
- develop
tags:
- 'v*'
paths:
- 'api/**'
- 'agents/k8s-agent/**'
- 'ui/**'
- '.github/workflows/container-images.yml'
pull_request:
branches:
- main
- develop
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }}/streamspace
permissions:
contents: write
packages: write
id-token: write
security-events: write
attestations: write
jobs:
build-and-sign-k8s-agent:
name: Build & Sign K8s Agent (v2.0)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3
with:
cosign-release: 'v2.2.2'
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE_PREFIX }}-k8s-agent
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}
- name: Set build variables
id: vars
run: |
echo "VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}" >> $GITHUB_OUTPUT
echo "COMMIT=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
- name: Build and push K8s Agent image
id: build
uses: docker/build-push-action@v7
with:
context: ./agents/k8s-agent
file: ./agents/k8s-agent/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.vars.outputs.VERSION }}
COMMIT=${{ steps.vars.outputs.COMMIT }}
BUILD_DATE=${{ steps.vars.outputs.BUILD_DATE }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: true
sbom: true
- name: Sign K8s Agent image
if: github.event_name != 'pull_request'
env:
COSIGN_EXPERIMENTAL: "true"
run: |
# Get the first tag from the metadata action
IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
echo "Image tag: $IMAGE_TAG"
# Retry logic for manifest propagation
MAX_RETRIES=5
RETRY_DELAY=2
for i in $(seq 1 $MAX_RETRIES); do
echo "Attempt $i of $MAX_RETRIES to fetch manifest digest..."
# Get the manifest digest using docker manifest inspect
# This returns the actual registry digest for multi-platform manifests
DIGEST=$(docker manifest inspect "$IMAGE_TAG" 2>&1 | jq -r '.digest // empty' || echo "")
# If jq didn't find .digest, try extracting from Docker-Content-Digest header
if [ -z "$DIGEST" ]; then
DIGEST=$(docker buildx imagetools inspect "$IMAGE_TAG" 2>&1 | grep -oP 'Digest:\s*\K(sha256:[a-f0-9]{64})' | head -n1 || echo "")
fi
# Validate digest format
if [[ "$DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "✅ Successfully extracted digest: $DIGEST"
break
else
echo "⚠️ Invalid digest format (attempt $i): $DIGEST"
if [ $i -eq $MAX_RETRIES ]; then
echo "ERROR: Failed to get valid digest after $MAX_RETRIES attempts"
echo "Full docker manifest inspect output:"
docker manifest inspect "$IMAGE_TAG" || true
echo "Full buildx imagetools output:"
docker buildx imagetools inspect "$IMAGE_TAG" || true
exit 1
fi
echo "Waiting ${RETRY_DELAY}s before retry..."
sleep $RETRY_DELAY
RETRY_DELAY=$((RETRY_DELAY * 2)) # Exponential backoff
fi
done
IMAGE_REF="${{ env.IMAGE_PREFIX }}-k8s-agent@${DIGEST}"
echo "Image reference for signing: $IMAGE_REF"
cosign sign --yes "$IMAGE_REF"
- name: Generate SBOM for K8s Agent
if: github.event_name != 'pull_request'
uses: anchore/sbom-action@v0
with:
path: ./agents/k8s-agent
artifact-name: streamspace-k8s-agent-sbom.spdx.json
output-file: sbom-k8s-agent.spdx.json
format: spdx-json
- name: Attest K8s Agent SBOM
if: github.event_name != 'pull_request'
env:
COSIGN_EXPERIMENTAL: "true"
run: |
IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
# Retry logic for manifest propagation
MAX_RETRIES=5
RETRY_DELAY=2
for i in $(seq 1 $MAX_RETRIES); do
echo "Attempt $i of $MAX_RETRIES to fetch manifest digest for SBOM attestation..."
DIGEST=$(docker manifest inspect "$IMAGE_TAG" 2>&1 | jq -r '.digest // empty' || echo "")
if [ -z "$DIGEST" ]; then
DIGEST=$(docker buildx imagetools inspect "$IMAGE_TAG" 2>&1 | grep -oP 'Digest:\s*\K(sha256:[a-f0-9]{64})' | head -n1 || echo "")
fi
if [[ "$DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "✅ Successfully extracted digest: $DIGEST"
break
else
if [ $i -eq $MAX_RETRIES ]; then
echo "ERROR: Failed to get valid digest after $MAX_RETRIES attempts"
exit 1
fi
echo "Waiting ${RETRY_DELAY}s before retry..."
sleep $RETRY_DELAY
RETRY_DELAY=$((RETRY_DELAY * 2))
fi
done
IMAGE_REF="${{ env.IMAGE_PREFIX }}-k8s-agent@${DIGEST}"
echo "Using digest for SBOM attestation: $DIGEST"
cosign attest --yes --type spdxjson \
--predicate sbom-k8s-agent.spdx.json \
"$IMAGE_REF"
- name: Upload K8s Agent SBOM
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v7
with:
name: sbom-k8s-agent
path: sbom-k8s-agent.spdx.json
retention-days: 90
build-and-sign-api:
name: Build & Sign API
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3
with:
cosign-release: 'v2.2.2'
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE_PREFIX }}-api
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}
- name: Set build variables
id: vars
run: |
echo "VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}" >> $GITHUB_OUTPUT
echo "COMMIT=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
- name: Build and push API image
id: build
uses: docker/build-push-action@v7
with:
context: ./api
file: ./api/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.vars.outputs.VERSION }}
COMMIT=${{ steps.vars.outputs.COMMIT }}
BUILD_DATE=${{ steps.vars.outputs.BUILD_DATE }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: true
sbom: true
- name: Sign API image
if: github.event_name != 'pull_request'
env:
COSIGN_EXPERIMENTAL: "true"
run: |
# Get the first tag from the metadata action
IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
echo "Image tag: $IMAGE_TAG"
# Retry logic for manifest propagation
MAX_RETRIES=5
RETRY_DELAY=2
for i in $(seq 1 $MAX_RETRIES); do
echo "Attempt $i of $MAX_RETRIES to fetch manifest digest..."
# Get the manifest digest using docker manifest inspect
# This returns the actual registry digest for multi-platform manifests
DIGEST=$(docker manifest inspect "$IMAGE_TAG" 2>&1 | jq -r '.digest // empty' || echo "")
# If jq didn't find .digest, try extracting from Docker-Content-Digest header
if [ -z "$DIGEST" ]; then
DIGEST=$(docker buildx imagetools inspect "$IMAGE_TAG" 2>&1 | grep -oP 'Digest:\s*\K(sha256:[a-f0-9]{64})' | head -n1 || echo "")
fi
# Validate digest format
if [[ "$DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "✅ Successfully extracted digest: $DIGEST"
break
else
echo "⚠️ Invalid digest format (attempt $i): $DIGEST"
if [ $i -eq $MAX_RETRIES ]; then
echo "ERROR: Failed to get valid digest after $MAX_RETRIES attempts"
echo "Full docker manifest inspect output:"
docker manifest inspect "$IMAGE_TAG" || true
echo "Full buildx imagetools output:"
docker buildx imagetools inspect "$IMAGE_TAG" || true
exit 1
fi
echo "Waiting ${RETRY_DELAY}s before retry..."
sleep $RETRY_DELAY
RETRY_DELAY=$((RETRY_DELAY * 2)) # Exponential backoff
fi
done
IMAGE_REF="${{ env.IMAGE_PREFIX }}-api@${DIGEST}"
echo "Image reference for signing: $IMAGE_REF"
cosign sign --yes "$IMAGE_REF"
- name: Generate SBOM for API
if: github.event_name != 'pull_request'
uses: anchore/sbom-action@v0
with:
path: ./api
artifact-name: streamspace-api-sbom.spdx.json
output-file: sbom-api.spdx.json
format: spdx-json
- name: Attest API SBOM
if: github.event_name != 'pull_request'
env:
COSIGN_EXPERIMENTAL: "true"
run: |
IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
# Retry logic for manifest propagation
MAX_RETRIES=5
RETRY_DELAY=2
for i in $(seq 1 $MAX_RETRIES); do
echo "Attempt $i of $MAX_RETRIES to fetch manifest digest for SBOM attestation..."
DIGEST=$(docker manifest inspect "$IMAGE_TAG" 2>&1 | jq -r '.digest // empty' || echo "")
if [ -z "$DIGEST" ]; then
DIGEST=$(docker buildx imagetools inspect "$IMAGE_TAG" 2>&1 | grep -oP 'Digest:\s*\K(sha256:[a-f0-9]{64})' | head -n1 || echo "")
fi
if [[ "$DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "✅ Successfully extracted digest: $DIGEST"
break
else
if [ $i -eq $MAX_RETRIES ]; then
echo "ERROR: Failed to get valid digest after $MAX_RETRIES attempts"
exit 1
fi
echo "Waiting ${RETRY_DELAY}s before retry..."
sleep $RETRY_DELAY
RETRY_DELAY=$((RETRY_DELAY * 2))
fi
done
IMAGE_REF="${{ env.IMAGE_PREFIX }}-api@${DIGEST}"
echo "Using digest for SBOM attestation: $DIGEST"
cosign attest --yes --type spdxjson \
--predicate sbom-api.spdx.json \
"$IMAGE_REF"
- name: Upload API SBOM
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v7
with:
name: sbom-api
path: sbom-api.spdx.json
retention-days: 90
build-and-sign-ui:
name: Build & Sign UI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3
with:
cosign-release: 'v2.2.2'
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE_PREFIX }}-ui
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}
- name: Set build variables
id: vars
run: |
echo "VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}" >> $GITHUB_OUTPUT
echo "COMMIT=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
- name: Build and push UI image
id: build
uses: docker/build-push-action@v7
with:
context: ./ui
file: ./ui/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.vars.outputs.VERSION }}
COMMIT=${{ steps.vars.outputs.COMMIT }}
BUILD_DATE=${{ steps.vars.outputs.BUILD_DATE }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: true
sbom: true
- name: Sign UI image
if: github.event_name != 'pull_request'
env:
COSIGN_EXPERIMENTAL: "true"
run: |
# Get the first tag from the metadata action
IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
echo "Image tag: $IMAGE_TAG"
# Retry logic for manifest propagation
MAX_RETRIES=5
RETRY_DELAY=2
for i in $(seq 1 $MAX_RETRIES); do
echo "Attempt $i of $MAX_RETRIES to fetch manifest digest..."
# Get the manifest digest using docker manifest inspect
# This returns the actual registry digest for multi-platform manifests
DIGEST=$(docker manifest inspect "$IMAGE_TAG" 2>&1 | jq -r '.digest // empty' || echo "")
# If jq didn't find .digest, try extracting from Docker-Content-Digest header
if [ -z "$DIGEST" ]; then
DIGEST=$(docker buildx imagetools inspect "$IMAGE_TAG" 2>&1 | grep -oP 'Digest:\s*\K(sha256:[a-f0-9]{64})' | head -n1 || echo "")
fi
# Validate digest format
if [[ "$DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "✅ Successfully extracted digest: $DIGEST"
break
else
echo "⚠️ Invalid digest format (attempt $i): $DIGEST"
if [ $i -eq $MAX_RETRIES ]; then
echo "ERROR: Failed to get valid digest after $MAX_RETRIES attempts"
echo "Full docker manifest inspect output:"
docker manifest inspect "$IMAGE_TAG" || true
echo "Full buildx imagetools output:"
docker buildx imagetools inspect "$IMAGE_TAG" || true
exit 1
fi
echo "Waiting ${RETRY_DELAY}s before retry..."
sleep $RETRY_DELAY
RETRY_DELAY=$((RETRY_DELAY * 2)) # Exponential backoff
fi
done
IMAGE_REF="${{ env.IMAGE_PREFIX }}-ui@${DIGEST}"
echo "Image reference for signing: $IMAGE_REF"
cosign sign --yes "$IMAGE_REF"
- name: Generate SBOM for UI
if: github.event_name != 'pull_request'
uses: anchore/sbom-action@v0
with:
path: ./ui
artifact-name: streamspace-ui-sbom.spdx.json
output-file: sbom-ui.spdx.json
format: spdx-json
- name: Attest UI SBOM
if: github.event_name != 'pull_request'
env:
COSIGN_EXPERIMENTAL: "true"
run: |
IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
# Retry logic for manifest propagation
MAX_RETRIES=5
RETRY_DELAY=2
for i in $(seq 1 $MAX_RETRIES); do
echo "Attempt $i of $MAX_RETRIES to fetch manifest digest for SBOM attestation..."
DIGEST=$(docker manifest inspect "$IMAGE_TAG" 2>&1 | jq -r '.digest // empty' || echo "")
if [ -z "$DIGEST" ]; then
DIGEST=$(docker buildx imagetools inspect "$IMAGE_TAG" 2>&1 | grep -oP 'Digest:\s*\K(sha256:[a-f0-9]{64})' | head -n1 || echo "")
fi
if [[ "$DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]; then
echo "✅ Successfully extracted digest: $DIGEST"
break
else
if [ $i -eq $MAX_RETRIES ]; then
echo "ERROR: Failed to get valid digest after $MAX_RETRIES attempts"
exit 1
fi
echo "Waiting ${RETRY_DELAY}s before retry..."
sleep $RETRY_DELAY
RETRY_DELAY=$((RETRY_DELAY * 2))
fi
done
IMAGE_REF="${{ env.IMAGE_PREFIX }}-ui@${DIGEST}"
echo "Using digest for SBOM attestation: $DIGEST"
cosign attest --yes --type spdxjson \
--predicate sbom-ui.spdx.json \
"$IMAGE_REF"
- name: Upload UI SBOM
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v7
with:
name: sbom-ui
path: sbom-ui.spdx.json
retention-days: 90
security-scan:
name: Security Scan
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
needs: [build-and-sign-k8s-agent, build-and-sign-api, build-and-sign-ui]
strategy:
matrix:
component: [k8s-agent, api, ui]
steps:
- name: Install Cosign
uses: sigstore/cosign-installer@v3
with:
cosign-release: 'v2.2.2'
- name: Verify image signature
env:
COSIGN_EXPERIMENTAL: "true"
run: |
cosign verify ${{ env.IMAGE_PREFIX }}-${{ matrix.component }}:latest
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.IMAGE_PREFIX }}-${{ matrix.component }}:latest
format: 'sarif'
output: 'trivy-${{ matrix.component }}-results.sarif'
severity: 'CRITICAL,HIGH'
- name: Upload Trivy results to GitHub Security
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: 'trivy-${{ matrix.component }}-results.sarif'
category: 'trivy-${{ matrix.component }}'
- name: Generate Trivy report
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.IMAGE_PREFIX }}-${{ matrix.component }}:latest
format: 'table'
severity: 'CRITICAL,HIGH,MEDIUM'
update-helm-chart:
name: Update Helm Chart
runs-on: ubuntu-latest
needs: [build-and-sign-k8s-agent, build-and-sign-api, build-and-sign-ui]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Update Chart.yaml
run: |
VERSION=${{ steps.version.outputs.VERSION }}
sed -i "s/^version:.*/version: ${VERSION#v}/" chart/Chart.yaml
sed -i "s/^appVersion:.*/appVersion: \"${VERSION}\"/" chart/Chart.yaml
- name: Update values.yaml
run: |
VERSION=${{ steps.version.outputs.VERSION }}
sed -i "s/tag: \".*\"/tag: \"${VERSION}\"/" chart/values.yaml
- name: Commit changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add chart/Chart.yaml chart/values.yaml
git commit -m "chore: bump chart version to ${{ steps.version.outputs.VERSION }}" || echo "No changes to commit"
git push origin HEAD:main || echo "No changes to push"
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [security-scan, update-helm-chart]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Extract version
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION_NUM=${VERSION#v}" >> $GITHUB_OUTPUT
- name: Generate changelog
id: changelog
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges)
else
CHANGELOG=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges)
fi
echo "$CHANGELOG" > CHANGELOG.txt
- name: Set up Helm
uses: azure/setup-helm@v5
with:
version: 'v3.14.0'
- name: Package Helm chart
run: |
helm package chart/ --version ${{ steps.version.outputs.VERSION_NUM }} --app-version ${{ steps.version.outputs.VERSION }}
mv streamspace-${{ steps.version.outputs.VERSION_NUM }}.tgz streamspace-helm-chart.tgz
- name: Download SBOMs
uses: actions/download-artifact@v8
with:
path: sboms
- name: Create Release Notes
run: |
cat > RELEASE_NOTES.md <<EOF
# StreamSpace ${{ steps.version.outputs.VERSION }} (v2.0 Multi-Platform Architecture)
## Architecture
StreamSpace v2.0 features a **multi-platform agent-based architecture**:
- Centralized Control Plane (API + UI)
- Platform-specific agents (K8s, Docker, VMs, Cloud)
- WebSocket-based agent communication
- VNC proxy tunneling
## Container Images
All images are multi-platform (linux/amd64, linux/arm64) and signed with Cosign:
- K8s Agent: \`${{ env.IMAGE_PREFIX }}-k8s-agent:${{ steps.version.outputs.VERSION }}\`
- Control Plane API: \`${{ env.IMAGE_PREFIX }}-api:${{ steps.version.outputs.VERSION }}\`
- Web UI: \`${{ env.IMAGE_PREFIX }}-ui:${{ steps.version.outputs.VERSION }}\`
## Security
✅ All images are signed with Cosign (keyless)
✅ SBOMs generated and attached
✅ Vulnerability scanned with Trivy
### Verifying Image Signatures
\`\`\`bash
cosign verify ${{ env.IMAGE_PREFIX }}-k8s-agent:${{ steps.version.outputs.VERSION }}
cosign verify ${{ env.IMAGE_PREFIX }}-api:${{ steps.version.outputs.VERSION }}
cosign verify ${{ env.IMAGE_PREFIX }}-ui:${{ steps.version.outputs.VERSION }}
\`\`\`
## Installation
### Using Helm
\`\`\`bash
helm install streamspace streamspace-helm-chart.tgz \\
--namespace streamspace \\
--create-namespace
\`\`\`
## What's Changed
$(cat CHANGELOG.txt)
## Documentation
- [README](https://github.com/${{ github.repository }}/blob/main/README.md)
- [Architecture](https://github.com/${{ github.repository }}/blob/main/docs/ARCHITECTURE.md)
- [Helm Chart](https://github.com/${{ github.repository }}/blob/main/chart/README.md)
EOF
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: RELEASE_NOTES.md
files: |
streamspace-helm-chart.tgz
sboms/**/*.spdx.json
draft: false
prerelease: ${{ contains(steps.version.outputs.VERSION, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-summary:
name: Build Summary (v2.0)
runs-on: ubuntu-latest
needs: [build-and-sign-k8s-agent, build-and-sign-api, build-and-sign-ui]
if: always()
steps:
- name: Generate summary
run: |
echo "## 🐳 StreamSpace v2.0 Container Images Built" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Architecture: Multi-Platform Agent-Based" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Images" >> $GITHUB_STEP_SUMMARY
echo "- ✅ \`${{ env.IMAGE_PREFIX }}-k8s-agent:latest\` (K8s Agent)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ \`${{ env.IMAGE_PREFIX }}-api:latest\` (Control Plane API)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ \`${{ env.IMAGE_PREFIX }}-ui:latest\` (Web UI)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Platforms" >> $GITHUB_STEP_SUMMARY
echo "- linux/amd64" >> $GITHUB_STEP_SUMMARY
echo "- linux/arm64" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Security Features" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Signed with Cosign" >> $GITHUB_STEP_SUMMARY
echo "- ✅ SBOM generated" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Provenance attestation" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Vulnerability scanned" >> $GITHUB_STEP_SUMMARY