-
Notifications
You must be signed in to change notification settings - Fork 1
588 lines (509 loc) · 21.1 KB
/
release.yml
File metadata and controls
588 lines (509 loc) · 21.1 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
name: Release
on:
push:
tags: ['v*']
env:
CARGO_TERM_COLOR: always
jobs:
# Validate that the tag matches the version in Cargo.toml
validate-version:
name: Validate Version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Extract version from tag
id: tag
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Extract version from Cargo.toml
id: cargo
run: |
version=$(grep -m1 'version = "' Cargo.toml | sed 's/.*version = "\([^"]*\)".*/\1/')
echo "version=$version" >> $GITHUB_OUTPUT
- name: Check version match
run: |
if [ "${{ steps.tag.outputs.version }}" != "${{ steps.cargo.outputs.version }}" ]; then
echo "::error::Tag version (${{ steps.tag.outputs.version }}) does not match Cargo.toml version (${{ steps.cargo.outputs.version }})"
exit 1
fi
echo "Version validated: ${{ steps.tag.outputs.version }}"
# Validate that CHANGELOG.md has an entry for this version
validate-changelog:
name: Validate Changelog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Extract version from tag
id: tag
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Check changelog entry
run: |
if ! grep -q "## \[${{ steps.tag.outputs.version }}\]" CHANGELOG.md; then
echo "::error::CHANGELOG.md does not contain an entry for version ${{ steps.tag.outputs.version }}"
echo "Expected to find: ## [${{ steps.tag.outputs.version }}]"
exit 1
fi
echo "Changelog entry found for version ${{ steps.tag.outputs.version }}"
# Build binaries for all supported platforms
build-binaries:
name: Build ${{ matrix.target }}
needs: [validate-version, validate-changelog]
strategy:
fail-fast: false
matrix:
include:
# Linux GNU targets
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cross: false
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: true
# Linux musl targets (static linking, requires cross for aws-lc-rs)
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
cross: true
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
cross: true
# macOS targets
- target: x86_64-apple-darwin
os: macos-14
cross: false
- target: aarch64-apple-darwin
os: macos-14
cross: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build data plane with cargo
if: ${{ !matrix.cross }}
run: cargo build --release --target ${{ matrix.target }} --package barbacane
- name: Build control plane with cargo
if: ${{ !matrix.cross }}
run: cargo build --release --target ${{ matrix.target }} --package barbacane-control
- name: Build data plane with cross
if: matrix.cross
run: cross build --release --target ${{ matrix.target }} --package barbacane
- name: Build control plane with cross
if: matrix.cross
run: cross build --release --target ${{ matrix.target }} --package barbacane-control
- name: Prepare artifacts
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/barbacane dist/barbacane-${{ matrix.target }}
cp target/${{ matrix.target }}/release/barbacane-control dist/barbacane-control-${{ matrix.target }}
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: binaries-${{ matrix.target }}
path: dist/
retention-days: 1
# Build container images per architecture using native runners
build-containers:
name: Build Containers (${{ matrix.platform }})
needs: [validate-version, validate-changelog]
strategy:
matrix:
include:
- platform: linux/amd64
os: ubuntu-latest
suffix: amd64
- platform: linux/arm64
os: ubuntu-24.04-arm # Native ARM64 Linux runner
suffix: arm64
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- name: Extract version from tag
id: tag
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push data plane
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: true
platforms: ${{ matrix.platform }}
tags: |
ghcr.io/${{ github.repository_owner }}/barbacane:${{ steps.tag.outputs.version }}-${{ matrix.suffix }}
docker.io/barbacane/barbacane:${{ steps.tag.outputs.version }}-${{ matrix.suffix }}
cache-from: type=gha,scope=barbacane-${{ matrix.suffix }}
cache-to: type=gha,mode=max,scope=barbacane-${{ matrix.suffix }}
- name: Build and push control plane
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile.control
push: true
platforms: ${{ matrix.platform }}
tags: |
ghcr.io/${{ github.repository_owner }}/barbacane-control:${{ steps.tag.outputs.version }}-${{ matrix.suffix }}
docker.io/barbacane/barbacane-control:${{ steps.tag.outputs.version }}-${{ matrix.suffix }}
cache-from: type=gha,scope=barbacane-control-${{ matrix.suffix }}
cache-to: type=gha,mode=max,scope=barbacane-control-${{ matrix.suffix }}
- name: Build and push standalone
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile.standalone
push: true
platforms: ${{ matrix.platform }}
tags: |
ghcr.io/${{ github.repository_owner }}/barbacane-standalone:${{ steps.tag.outputs.version }}-${{ matrix.suffix }}
docker.io/barbacane/barbacane-standalone:${{ steps.tag.outputs.version }}-${{ matrix.suffix }}
cache-from: type=gha,scope=barbacane-standalone-${{ matrix.suffix }}
cache-to: type=gha,mode=max,scope=barbacane-standalone-${{ matrix.suffix }}
# Create multi-arch manifests combining platform-specific images
create-manifests:
name: Create Multi-arch Manifests
needs: [validate-version, build-containers]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Extract version from tag
id: tag
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Extract version components
id: version
run: |
VERSION=${{ steps.tag.outputs.version }}
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f1-2)
echo "major=$MAJOR" >> $GITHUB_OUTPUT
echo "minor=$MINOR" >> $GITHUB_OUTPUT
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create GHCR data plane manifest
run: |
VERSION=${{ steps.tag.outputs.version }}
docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/barbacane:latest \
-t ghcr.io/${{ github.repository_owner }}/barbacane:$VERSION \
-t ghcr.io/${{ github.repository_owner }}/barbacane:${{ steps.version.outputs.minor }} \
-t ghcr.io/${{ github.repository_owner }}/barbacane:${{ steps.version.outputs.major }} \
ghcr.io/${{ github.repository_owner }}/barbacane:$VERSION-amd64 \
ghcr.io/${{ github.repository_owner }}/barbacane:$VERSION-arm64
- name: Create GHCR control plane manifest
run: |
VERSION=${{ steps.tag.outputs.version }}
docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/barbacane-control:latest \
-t ghcr.io/${{ github.repository_owner }}/barbacane-control:$VERSION \
-t ghcr.io/${{ github.repository_owner }}/barbacane-control:${{ steps.version.outputs.minor }} \
-t ghcr.io/${{ github.repository_owner }}/barbacane-control:${{ steps.version.outputs.major }} \
ghcr.io/${{ github.repository_owner }}/barbacane-control:$VERSION-amd64 \
ghcr.io/${{ github.repository_owner }}/barbacane-control:$VERSION-arm64
- name: Create Docker Hub data plane manifest
run: |
VERSION=${{ steps.tag.outputs.version }}
docker buildx imagetools create -t docker.io/barbacane/barbacane:latest \
-t docker.io/barbacane/barbacane:$VERSION \
-t docker.io/barbacane/barbacane:${{ steps.version.outputs.minor }} \
-t docker.io/barbacane/barbacane:${{ steps.version.outputs.major }} \
docker.io/barbacane/barbacane:$VERSION-amd64 \
docker.io/barbacane/barbacane:$VERSION-arm64
- name: Create Docker Hub control plane manifest
run: |
VERSION=${{ steps.tag.outputs.version }}
docker buildx imagetools create -t docker.io/barbacane/barbacane-control:latest \
-t docker.io/barbacane/barbacane-control:$VERSION \
-t docker.io/barbacane/barbacane-control:${{ steps.version.outputs.minor }} \
-t docker.io/barbacane/barbacane-control:${{ steps.version.outputs.major }} \
docker.io/barbacane/barbacane-control:$VERSION-amd64 \
docker.io/barbacane/barbacane-control:$VERSION-arm64
- name: Create GHCR standalone manifest
run: |
VERSION=${{ steps.tag.outputs.version }}
docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/barbacane-standalone:latest \
-t ghcr.io/${{ github.repository_owner }}/barbacane-standalone:$VERSION \
-t ghcr.io/${{ github.repository_owner }}/barbacane-standalone:${{ steps.version.outputs.minor }} \
-t ghcr.io/${{ github.repository_owner }}/barbacane-standalone:${{ steps.version.outputs.major }} \
ghcr.io/${{ github.repository_owner }}/barbacane-standalone:$VERSION-amd64 \
ghcr.io/${{ github.repository_owner }}/barbacane-standalone:$VERSION-arm64
- name: Create Docker Hub standalone manifest
run: |
VERSION=${{ steps.tag.outputs.version }}
docker buildx imagetools create -t docker.io/barbacane/barbacane-standalone:latest \
-t docker.io/barbacane/barbacane-standalone:$VERSION \
-t docker.io/barbacane/barbacane-standalone:${{ steps.version.outputs.minor }} \
-t docker.io/barbacane/barbacane-standalone:${{ steps.version.outputs.major }} \
docker.io/barbacane/barbacane-standalone:$VERSION-amd64 \
docker.io/barbacane/barbacane-standalone:$VERSION-arm64
# Security scan the multi-arch images
scan-containers:
name: Scan Containers
needs: [validate-version, create-manifests]
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
security-events: write
steps:
- uses: actions/checkout@v6
- name: Extract version from tag
id: tag
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Security scan images
- name: Scan data plane image
uses: aquasecurity/trivy-action@master
with:
image-ref: ghcr.io/${{ github.repository_owner }}/barbacane:${{ steps.tag.outputs.version }}
format: 'sarif'
output: 'trivy-data-plane.sarif'
severity: 'CRITICAL,HIGH'
- name: Scan control plane image
uses: aquasecurity/trivy-action@master
with:
image-ref: ghcr.io/${{ github.repository_owner }}/barbacane-control:${{ steps.tag.outputs.version }}
format: 'sarif'
output: 'trivy-control-plane.sarif'
severity: 'CRITICAL,HIGH'
- name: Upload data plane scan results
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: 'trivy-data-plane.sarif'
category: 'trivy-data-plane'
- name: Upload control plane scan results
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: 'trivy-control-plane.sarif'
category: 'trivy-control-plane'
- name: Scan standalone image
uses: aquasecurity/trivy-action@master
with:
image-ref: ghcr.io/${{ github.repository_owner }}/barbacane-standalone:${{ steps.tag.outputs.version }}
format: 'sarif'
output: 'trivy-standalone.sarif'
severity: 'CRITICAL,HIGH'
- name: Upload standalone scan results
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: 'trivy-standalone.sarif'
category: 'trivy-standalone'
# Publish crates to crates.io
publish-crates:
name: Publish Crates
needs: [validate-version, validate-changelog]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
# Publish in dependency order (leaves first, roots last)
# Wait between publishes for crates.io index to update
# Track failures to report at the end
- name: Publish all crates
id: publish
run: |
FAILED=""
SKIPPED=""
SUCCESS=""
publish_crate() {
local crate=$1
echo "::group::Publishing $crate"
# Capture output and exit code
set +e
OUTPUT=$(cargo publish -p "$crate" --token ${{ secrets.CARGO_REGISTRY_TOKEN }} 2>&1)
EXIT_CODE=$?
set -e
echo "$OUTPUT"
if [ $EXIT_CODE -eq 0 ]; then
echo "✓ $crate published successfully"
SUCCESS="$SUCCESS $crate"
elif echo "$OUTPUT" | grep -qE "already uploaded|already exists"; then
echo "⊘ $crate already published, skipping"
SKIPPED="$SKIPPED $crate"
else
echo "✗ $crate failed to publish"
FAILED="$FAILED $crate"
fi
echo "::endgroup::"
# Wait for crates.io index to update and avoid rate limits
# New crate names have stricter limits than version updates
sleep 60
}
# Publish in dependency order
publish_crate "barbacane-plugin-macros"
publish_crate "barbacane-plugin-sdk"
publish_crate "barbacane-telemetry"
publish_crate "barbacane-wasm"
publish_crate "barbacane-compiler"
publish_crate "barbacane"
publish_crate "barbacane-control"
# Summary
echo ""
echo "=========================================="
echo "Publish Summary"
echo "=========================================="
if [ -n "$SUCCESS" ]; then
echo "✓ Published:$SUCCESS"
fi
if [ -n "$SKIPPED" ]; then
echo "⊘ Already published:$SKIPPED"
fi
if [ -n "$FAILED" ]; then
echo "✗ Failed:$FAILED"
echo ""
echo "::error::Some crates failed to publish:$FAILED"
exit 1
fi
echo ""
echo "All crates published successfully!"
# Build WASM plugins and collect artifacts for release
build-plugins:
name: Build Plugins
needs: [validate-version, validate-changelog]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-plugins-${{ hashFiles('plugins/**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-plugins-
- name: Build all plugins
run: |
mkdir -p dist/plugins
for plugin_dir in plugins/*/; do
if [ -f "$plugin_dir/Cargo.toml" ]; then
name=$(basename "$plugin_dir")
echo "::group::Building $name"
(cd "$plugin_dir" && cargo build --release --target wasm32-unknown-unknown)
# Find the .wasm output (exclude deps)
wasm_file=$(ls "$plugin_dir/target/wasm32-unknown-unknown/release/"*.wasm 2>/dev/null | grep -v deps | head -1)
if [ -n "$wasm_file" ]; then
cp "$wasm_file" "dist/plugins/$name.wasm"
echo " -> $name.wasm ($(du -h "dist/plugins/$name.wasm" | cut -f1))"
else
echo "::warning::No .wasm output found for $name"
fi
# Copy plugin.toml if present
if [ -f "$plugin_dir/plugin.toml" ]; then
cp "$plugin_dir/plugin.toml" "dist/plugins/$name.plugin.toml"
fi
echo "::endgroup::"
fi
done
- name: Generate plugin checksums
run: |
cd dist/plugins
sha256sum *.wasm > plugin-checksums.txt
cat plugin-checksums.txt
- name: Upload plugin artifacts
uses: actions/upload-artifact@v7
with:
name: plugins
path: dist/plugins/
retention-days: 1
# Create GitHub Release with all artifacts
create-release:
name: Create Release
needs: [build-binaries, build-plugins, create-manifests, scan-containers, publish-crates]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Extract version from tag
id: tag
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Download binary artifacts
uses: actions/download-artifact@v8
with:
path: artifacts/binaries
pattern: binaries-*
merge-multiple: true
- name: Download plugin artifacts
uses: actions/download-artifact@v8
with:
name: plugins
path: artifacts/plugins
- name: Prepare release artifacts
run: |
mkdir -p artifacts/release
# Binaries
cp artifacts/binaries/* artifacts/release/
# Plugins (.wasm and .plugin.toml files)
cp artifacts/plugins/*.wasm artifacts/release/
cp artifacts/plugins/*.plugin.toml artifacts/release/
cp artifacts/plugins/plugin-checksums.txt artifacts/release/
- name: Generate checksums
run: |
cd artifacts/release
# Checksums for binaries (plugins have their own file)
binaries=$(ls barbacane-* barbacane-control-* 2>/dev/null || true)
if [ -n "$binaries" ]; then
sha256sum $binaries > checksums.txt
cat checksums.txt
else
echo "::warning::No binary files found for checksums"
fi
- name: Extract release notes from changelog
id: changelog
run: |
# Extract the section for this version from CHANGELOG.md
VERSION=${{ steps.tag.outputs.version }}
awk "/^## \[$VERSION\]/,/^## \[/{if(/^## \[/ && !/^## \[$VERSION\]/)exit; print}" CHANGELOG.md > release-notes.md
# Remove the header line
tail -n +2 release-notes.md > release-notes-trimmed.md
mv release-notes-trimmed.md release-notes.md
echo "Release notes:"
cat release-notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Barbacane v${{ steps.tag.outputs.version }}
body_path: release-notes.md
files: |
artifacts/release/*
draft: false
prerelease: ${{ contains(steps.tag.outputs.version, '-') }}