-
Notifications
You must be signed in to change notification settings - Fork 45
1084 lines (934 loc) · 37.9 KB
/
publish.yml
File metadata and controls
1084 lines (934 loc) · 37.9 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
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Publish Package
on:
workflow_dispatch:
inputs:
package:
description: "Package to publish"
required: true
type: choice
options:
- all
- main
- sdk
default: "all"
version:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
- prepatch
- preminor
- premajor
- prerelease
custom_version:
description: "Custom version (optional, overrides version type)"
required: false
type: string
dry_run:
description: "Dry run (do not actually publish)"
required: false
type: boolean
default: false
tag:
description: "NPM dist-tag"
required: false
type: choice
options:
- latest
- next
- beta
- alpha
default: "latest"
# Prevent concurrent publishes
concurrency:
group: publish-package
cancel-in-progress: false
permissions:
contents: write
id-token: write
env:
NPM_CONFIG_FUND: false
jobs:
# Build Rust binaries for all platforms (in parallel)
build-binaries:
name: Build relay-pty (${{ matrix.target }})
runs-on: ${{ matrix.os }}
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'main'
strategy:
matrix:
include:
- os: macos-latest
target: aarch64-apple-darwin
binary_name: relay-pty-darwin-arm64
- os: macos-latest
target: x86_64-apple-darwin
binary_name: relay-pty-darwin-x64
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary_name: relay-pty-linux-x64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
binary_name: relay-pty-linux-arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: relay-pty
key: ${{ matrix.target }}
- name: Build relay-pty
working-directory: relay-pty
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Copy binary with platform name
run: cp relay-pty/target/${{ matrix.target }}/release/relay-pty bin/${{ matrix.binary_name }}
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.binary_name }}
path: bin/${{ matrix.binary_name }}
retention-days: 1
# Build standalone binaries using bun compile (cross-platform, no Node.js required)
build-standalone:
name: Build standalone (${{ matrix.target }})
needs: build # Wait for version bump
runs-on: ${{ matrix.os }}
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'main'
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
target: bun-darwin-arm64
binary_name: agent-relay-darwin-arm64
- os: macos-latest
target: bun-darwin-x64
binary_name: agent-relay-darwin-x64
- os: ubuntu-latest
target: bun-linux-x64
binary_name: agent-relay-linux-x64
- os: ubuntu-latest
target: bun-linux-arm64
binary_name: agent-relay-linux-arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build TypeScript
run: npm run build
- name: Build standalone binary
run: |
mkdir -p release-binaries
# Exclude native modules - bun runtime has built-in bun:sqlite
bun build \
--compile \
--minify \
--target=${{ matrix.target }} \
--external=better-sqlite3 \
--external=ssh2 \
--define="process.env.AGENT_RELAY_VERSION=\"${{ needs.build.outputs.new_version }}\"" \
./dist/src/cli/index.js \
--outfile release-binaries/${{ matrix.binary_name }}
- name: Verify binary
if: matrix.target == 'bun-linux-x64' || (matrix.target == 'bun-darwin-arm64' && runner.arch == 'ARM64')
run: |
chmod +x release-binaries/${{ matrix.binary_name }}
./release-binaries/${{ matrix.binary_name }} --version || echo "Binary created (cross-compiled)"
- name: Compress binary with gzip
run: |
gzip -9 -k release-binaries/${{ matrix.binary_name }}
echo "Uncompressed: $(du -h release-binaries/${{ matrix.binary_name }} | cut -f1)"
echo "Compressed: $(du -h release-binaries/${{ matrix.binary_name }}.gz | cut -f1)"
- name: Upload compressed binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.binary_name }}.gz
path: release-binaries/${{ matrix.binary_name }}.gz
retention-days: 1
- name: Upload uncompressed binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.binary_name }}
path: release-binaries/${{ matrix.binary_name }}
retention-days: 1
# Build relay-acp standalone binary for Zed editor integration
build-acp-standalone:
name: Build relay-acp (${{ matrix.target }})
needs: build
runs-on: ${{ matrix.os }}
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'main'
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
target: bun-darwin-arm64
binary_name: relay-acp-darwin-arm64
- os: macos-latest
target: bun-darwin-x64
binary_name: relay-acp-darwin-x64
- os: ubuntu-latest
target: bun-linux-x64
binary_name: relay-acp-linux-x64
- os: ubuntu-latest
target: bun-linux-arm64
binary_name: relay-acp-linux-arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build TypeScript
run: npm run build
- name: Build relay-acp standalone binary
run: |
mkdir -p release-binaries
bun build \
--compile \
--minify \
--target=${{ matrix.target }} \
--define="process.env.AGENT_RELAY_VERSION=\"${{ needs.build.outputs.new_version }}\"" \
./packages/acp-bridge/dist/cli.js \
--outfile release-binaries/${{ matrix.binary_name }}
- name: Verify binary
if: matrix.target == 'bun-linux-x64' || (matrix.target == 'bun-darwin-arm64' && runner.arch == 'ARM64')
run: |
chmod +x release-binaries/${{ matrix.binary_name }}
./release-binaries/${{ matrix.binary_name }} --version || echo "Binary created (cross-compiled)"
- name: Compress binary with gzip
run: |
gzip -9 -k release-binaries/${{ matrix.binary_name }}
echo "Uncompressed: $(du -h release-binaries/${{ matrix.binary_name }} | cut -f1)"
echo "Compressed: $(du -h release-binaries/${{ matrix.binary_name }}.gz | cut -f1)"
- name: Upload compressed binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.binary_name }}.gz
path: release-binaries/${{ matrix.binary_name }}.gz
retention-days: 1
- name: Upload uncompressed binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.binary_name }}
path: release-binaries/${{ matrix.binary_name }}
retention-days: 1
# Build all packages once, version them, and upload
build:
name: Build & Version
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.bump.outputs.new_version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
cache-dependency-path: package-lock.json
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci
- name: Ensure rollup optional dependencies are installed
run: npm install --no-save rollup || true
- name: Version all packages
id: bump
run: |
CUSTOM_VERSION="${{ github.event.inputs.custom_version }}"
VERSION_TYPE="${{ github.event.inputs.version }}"
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "Current version: $CURRENT_VERSION"
if [ -n "$CUSTOM_VERSION" ]; then
echo "Setting version to custom value: $CUSTOM_VERSION"
npm version "$CUSTOM_VERSION" --no-git-tag-version --allow-same-version
else
echo "Bumping version: $VERSION_TYPE"
npm version "$VERSION_TYPE" --no-git-tag-version --preid=beta
fi
NEW_VERSION=$(node -p "require('./package.json').version")
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION"
# Sync all package versions and internal dependencies using node script
# (avoids npm version which validates dependencies against registry)
node -e "
const fs = require('fs');
const path = require('path');
const version = '$NEW_VERSION';
// Update root package internal dependencies
const rootPkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
for (const dep of Object.keys(rootPkg.dependencies || {})) {
if (dep.startsWith('@agent-relay/')) {
rootPkg.dependencies[dep] = version;
}
}
fs.writeFileSync('package.json', JSON.stringify(rootPkg, null, 2) + '\n');
// Update all sub-packages: version + internal dependencies
const packagesDir = 'packages';
for (const dir of fs.readdirSync(packagesDir)) {
const pkgPath = path.join(packagesDir, dir, 'package.json');
if (fs.existsSync(pkgPath)) {
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
// Update package version
pkg.version = version;
console.log('@agent-relay/' + dir);
console.log('v' + version);
// Update internal dependencies
for (const dep of Object.keys(pkg.dependencies || {})) {
if (dep.startsWith('@agent-relay/')) {
pkg.dependencies[dep] = version;
}
}
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
}
}
"
- name: Clean reinstall after version bump
run: |
# Clear npm cache and node_modules to ensure fresh platform-specific deps
npm cache clean --force
rm -rf node_modules packages/*/node_modules package-lock.json
npm install
- name: Ensure rollup optional dependencies are installed
run: npm install --no-save rollup || true
- name: Build all packages
run: npm run build
- name: Run tests
run: npm test
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-output
path: |
package.json
package-lock.json
packages/*/package.json
packages/*/dist/
dist/
retention-days: 1
# Publish all packages in parallel (npm publish doesn't need deps published first)
publish-packages:
name: Publish ${{ matrix.package }}
needs: build
runs-on: ubuntu-latest
if: github.event.inputs.package == 'all'
strategy:
fail-fast: false
max-parallel: 10
matrix:
package:
# All packages - published in parallel
- protocol
- storage
- state
- policy
- memory
- utils
- continuity
- trajectory
- hooks
- resiliency
- user-directory
- api-types
- spawner
- mcp
- config
- bridge
- wrapper
- sdk
- daemon
- telemetry
- acp-bridge
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output
path: .
- name: Update npm for OIDC support
run: npm install -g npm@latest
- name: Dry run check
if: github.event.inputs.dry_run == 'true'
working-directory: packages/${{ matrix.package }}
run: |
echo "Dry run - would publish @agent-relay/${{ matrix.package }}"
npm publish --dry-run --access public --tag ${{ github.event.inputs.tag }} --ignore-scripts
- name: Publish to NPM
if: github.event.inputs.dry_run != 'true'
working-directory: packages/${{ matrix.package }}
run: npm publish --access public --provenance --tag ${{ github.event.inputs.tag }} --ignore-scripts
# Publish SDK only (when selected)
publish-sdk-only:
name: Publish SDK to NPM
needs: build
runs-on: ubuntu-latest
if: github.event.inputs.package == 'sdk'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output
path: .
- name: Update npm for OIDC support
run: npm install -g npm@latest
- name: Dry run check
if: github.event.inputs.dry_run == 'true'
working-directory: packages/sdk
run: npm publish --dry-run --access public --tag ${{ github.event.inputs.tag }} --ignore-scripts
- name: Publish SDK to NPM
if: github.event.inputs.dry_run != 'true'
working-directory: packages/sdk
run: npm publish --access public --provenance --tag ${{ github.event.inputs.tag }} --ignore-scripts
# Pre-publish verification: ensure all binaries are valid before publishing
verify-binaries-linux:
name: Verify Binaries (Linux)
needs: [build, build-binaries]
runs-on: ubuntu-latest
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'main'
steps:
- name: Download all binaries
uses: actions/download-artifact@v4
with:
pattern: relay-pty-*
path: bin/
merge-multiple: true
- name: List downloaded binaries
run: |
echo "Downloaded binaries:"
ls -la bin/
- name: Verify all platform binaries exist
run: |
MISSING=0
for BINARY in relay-pty-darwin-arm64 relay-pty-darwin-x64 relay-pty-linux-x64 relay-pty-linux-arm64; do
if [ -f "bin/$BINARY" ]; then
echo "✓ $BINARY exists ($(stat -c%s "bin/$BINARY" 2>/dev/null || stat -f%z "bin/$BINARY") bytes)"
else
echo "✗ $BINARY MISSING"
MISSING=1
fi
done
if [ $MISSING -eq 1 ]; then
echo ""
echo "ERROR: Some binaries are missing! Cannot publish."
exit 1
fi
echo ""
echo "All platform binaries present."
- name: Make binaries executable
run: chmod +x bin/relay-pty-*
- name: Verify Linux binary works
run: |
echo "Testing relay-pty-linux-x64 --help..."
OUTPUT=$(./bin/relay-pty-linux-x64 --help 2>&1) || true
echo "$OUTPUT"
if echo "$OUTPUT" | grep -q "PTY wrapper"; then
echo "✓ Linux x64 binary works"
else
echo "✗ Linux x64 binary failed --help test"
exit 1
fi
- name: Verify binary sizes are reasonable
run: |
# Binaries should be at least 1MB (to catch empty/corrupt files)
MIN_SIZE=1000000
for BINARY in bin/relay-pty-*; do
SIZE=$(stat -c%s "$BINARY" 2>/dev/null || stat -f%z "$BINARY")
if [ "$SIZE" -lt "$MIN_SIZE" ]; then
echo "✗ $BINARY is suspiciously small: $SIZE bytes"
exit 1
fi
echo "✓ $BINARY size OK: $SIZE bytes"
done
- name: Summary
run: |
echo "## Pre-Publish Binary Verification (Linux)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Binary | Status | Size |" >> $GITHUB_STEP_SUMMARY
echo "|--------|--------|------|" >> $GITHUB_STEP_SUMMARY
for BINARY in bin/relay-pty-*; do
NAME=$(basename "$BINARY")
SIZE=$(stat -c%s "$BINARY" 2>/dev/null || stat -f%z "$BINARY")
SIZE_MB=$(echo "scale=2; $SIZE / 1048576" | bc)
echo "| $NAME | ✅ | ${SIZE_MB}MB |" >> $GITHUB_STEP_SUMMARY
done
# Verify macOS binaries actually work on macOS (critical - catches issues before publish)
verify-binaries-macos:
name: Verify Binaries (macOS ${{ matrix.arch }})
needs: [build-binaries]
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'main'
strategy:
fail-fast: true
matrix:
include:
- os: macos-latest
arch: arm64
binary: relay-pty-darwin-arm64
runs-on: ${{ matrix.os }}
steps:
- name: Download binary
uses: actions/download-artifact@v4
with:
name: ${{ matrix.binary }}
path: bin/
- name: Make binary executable
run: chmod +x bin/${{ matrix.binary }}
- name: Verify binary exists and has reasonable size
run: |
if [ ! -f "bin/${{ matrix.binary }}" ]; then
echo "ERROR: Binary not found!"
exit 1
fi
SIZE=$(stat -f%z "bin/${{ matrix.binary }}")
echo "Binary size: $SIZE bytes"
# Should be at least 1MB
if [ "$SIZE" -lt 1000000 ]; then
echo "ERROR: Binary is suspiciously small!"
exit 1
fi
echo "✓ Binary exists with valid size"
- name: Test binary --help
run: |
echo "Testing ${{ matrix.binary }} --help..."
OUTPUT=$(./bin/${{ matrix.binary }} --help 2>&1) || true
echo "$OUTPUT"
if echo "$OUTPUT" | grep -q "PTY wrapper"; then
echo "✓ ${{ matrix.binary }} --help works"
else
echo "✗ ${{ matrix.binary }} --help failed!"
exit 1
fi
- name: Summary
run: |
echo "## macOS ${{ matrix.arch }} Binary Verification" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ **${{ matrix.binary }}** verified on macOS ${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY
# Verify standalone binaries on Linux
verify-standalone-linux:
name: Verify Standalone (Linux)
needs: [build-standalone]
runs-on: ubuntu-latest
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'main'
steps:
- name: Download Linux binary
uses: actions/download-artifact@v4
with:
name: agent-relay-linux-x64
path: bin/
- name: Download compressed binary
uses: actions/download-artifact@v4
with:
name: agent-relay-linux-x64.gz
path: bin/
- name: Verify uncompressed binary
run: |
chmod +x bin/agent-relay-linux-x64
echo "Testing uncompressed binary..."
./bin/agent-relay-linux-x64 --version
echo "✓ Uncompressed binary works"
- name: Verify compressed binary
run: |
echo "Testing compressed binary decompression..."
gunzip -c bin/agent-relay-linux-x64.gz > /tmp/agent-relay-test
chmod +x /tmp/agent-relay-test
/tmp/agent-relay-test --version
echo "✓ Compressed binary decompresses and works"
- name: Verify compression ratio
run: |
UNCOMPRESSED=$(stat -c%s bin/agent-relay-linux-x64)
COMPRESSED=$(stat -c%s bin/agent-relay-linux-x64.gz)
RATIO=$(echo "scale=0; 100 - ($COMPRESSED * 100 / $UNCOMPRESSED)" | bc)
echo "Compression ratio: ${RATIO}% reduction"
echo "Uncompressed: $(echo "scale=2; $UNCOMPRESSED / 1048576" | bc)MB"
echo "Compressed: $(echo "scale=2; $COMPRESSED / 1048576" | bc)MB"
# Verify reasonable compression (should be at least 50%)
if [ "$RATIO" -lt 50 ]; then
echo "WARNING: Compression ratio is lower than expected"
else
echo "✓ Compression ratio is good"
fi
# Verify standalone binaries on macOS
verify-standalone-macos:
name: Verify Standalone (macOS)
needs: [build-standalone]
runs-on: macos-latest
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'main'
steps:
- name: Download macOS binary
uses: actions/download-artifact@v4
with:
name: agent-relay-darwin-arm64
path: bin/
- name: Download compressed binary
uses: actions/download-artifact@v4
with:
name: agent-relay-darwin-arm64.gz
path: bin/
- name: Verify uncompressed binary
run: |
chmod +x bin/agent-relay-darwin-arm64
echo "Testing uncompressed binary..."
./bin/agent-relay-darwin-arm64 --version
echo "✓ Uncompressed binary works"
- name: Verify compressed binary
run: |
echo "Testing compressed binary decompression..."
gunzip -c bin/agent-relay-darwin-arm64.gz > /tmp/agent-relay-test
chmod +x /tmp/agent-relay-test
/tmp/agent-relay-test --version
echo "✓ Compressed binary decompresses and works"
# Verify relay-acp binaries on Linux
verify-acp-linux:
name: Verify relay-acp (Linux)
needs: [build-acp-standalone]
runs-on: ubuntu-latest
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'main'
steps:
- name: Download Linux binary
uses: actions/download-artifact@v4
with:
name: relay-acp-linux-x64
path: bin/
- name: Download compressed binary
uses: actions/download-artifact@v4
with:
name: relay-acp-linux-x64.gz
path: bin/
- name: Verify uncompressed binary
run: |
chmod +x bin/relay-acp-linux-x64
echo "Testing uncompressed binary..."
./bin/relay-acp-linux-x64 --help
echo "✓ Uncompressed relay-acp binary works"
- name: Verify compressed binary
run: |
echo "Testing compressed binary decompression..."
gunzip -c bin/relay-acp-linux-x64.gz > /tmp/relay-acp-test
chmod +x /tmp/relay-acp-test
/tmp/relay-acp-test --help
echo "✓ Compressed relay-acp binary decompresses and works"
# Verify relay-acp binaries on macOS
verify-acp-macos:
name: Verify relay-acp (macOS)
needs: [build-acp-standalone]
runs-on: macos-latest
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'main'
steps:
- name: Download macOS binary
uses: actions/download-artifact@v4
with:
name: relay-acp-darwin-arm64
path: bin/
- name: Download compressed binary
uses: actions/download-artifact@v4
with:
name: relay-acp-darwin-arm64.gz
path: bin/
- name: Verify uncompressed binary
run: |
chmod +x bin/relay-acp-darwin-arm64
echo "Testing uncompressed binary..."
./bin/relay-acp-darwin-arm64 --help
echo "✓ Uncompressed relay-acp binary works"
- name: Verify compressed binary
run: |
echo "Testing compressed binary decompression..."
gunzip -c bin/relay-acp-darwin-arm64.gz > /tmp/relay-acp-test
chmod +x /tmp/relay-acp-test
/tmp/relay-acp-test --help
echo "✓ Compressed relay-acp binary decompresses and works"
# Gate job that requires both Linux and macOS verification to pass
verify-binaries:
name: All Binaries Verified
needs: [verify-binaries-linux, verify-binaries-macos, verify-standalone-linux, verify-standalone-macos, verify-acp-linux, verify-acp-macos]
runs-on: ubuntu-latest
if: github.event.inputs.package == 'all' || github.event.inputs.package == 'main'
steps:
- name: All binary checks passed
run: |
echo "✅ All binary verification checks passed!"
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Binary Verification Gate" >> $GITHUB_STEP_SUMMARY
echo "✅ All platform binaries verified and ready for publish" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Verified Binaries" >> $GITHUB_STEP_SUMMARY
echo "- relay-pty: Linux x64, Linux ARM64, macOS x64, macOS ARM64" >> $GITHUB_STEP_SUMMARY
echo "- agent-relay: Linux x64, macOS ARM64 (both compressed and uncompressed)" >> $GITHUB_STEP_SUMMARY
echo "- relay-acp: Linux x64, macOS ARM64 (both compressed and uncompressed)" >> $GITHUB_STEP_SUMMARY
# Publish main package
publish-main:
name: Publish Main Package
needs: [build, build-binaries, verify-binaries, publish-packages]
runs-on: ubuntu-latest
if: |
always() &&
(github.event.inputs.package == 'all' || github.event.inputs.package == 'main') &&
needs.build.result == 'success' &&
needs.verify-binaries.result == 'success' &&
(needs.publish-packages.result == 'success' || needs.publish-packages.result == 'skipped')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output
path: .
- name: Download relay-pty binaries
uses: actions/download-artifact@v4
with:
pattern: relay-pty-*
path: bin/
merge-multiple: true
- name: Make binaries executable
run: chmod +x bin/relay-pty-*
- name: Update npm for OIDC support
run: npm install -g npm@latest
- name: Dry run check
if: github.event.inputs.dry_run == 'true'
run: |
echo "Dry run - would publish agent-relay@${{ needs.build.outputs.new_version }}"
npm publish --dry-run --access public --tag ${{ github.event.inputs.tag }} --ignore-scripts
- name: Publish to NPM
if: github.event.inputs.dry_run != 'true'
run: npm publish --access public --provenance --tag ${{ github.event.inputs.tag }} --ignore-scripts
# Create git tag and release
create-release:
name: Create Release
needs: [build, build-binaries, build-standalone, build-acp-standalone, verify-binaries, publish-main]
runs-on: ubuntu-latest
if: |
always() &&
github.event.inputs.dry_run != 'true' &&
needs.publish-main.result == 'success'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output
path: .
- name: Download relay-pty binaries
uses: actions/download-artifact@v4
with:
pattern: relay-pty-*
path: release-binaries/
merge-multiple: true
- name: Download standalone binaries (uncompressed)
uses: actions/download-artifact@v4
with:
pattern: agent-relay-*
path: release-binaries/
merge-multiple: true
- name: Download relay-acp binaries
uses: actions/download-artifact@v4
with:
pattern: relay-acp-*
path: release-binaries/
merge-multiple: true
- name: Make binaries executable
run: |
# Make uncompressed binaries executable (skip .gz files)
for f in release-binaries/*; do
if [[ "$f" != *.gz ]]; then
chmod +x "$f"
fi
done
- name: Verify all binaries present
run: |
echo "=== Verifying release binaries ==="
ls -la release-binaries/
MISSING=0
# Check relay-pty binaries
for BINARY in relay-pty-darwin-arm64 relay-pty-darwin-x64 relay-pty-linux-x64 relay-pty-linux-arm64; do
if [ -f "release-binaries/$BINARY" ]; then
echo "✓ $BINARY"
else
echo "✗ MISSING: $BINARY"
MISSING=1
fi
done
# Check standalone binaries (both compressed and uncompressed)
for BINARY in agent-relay-darwin-arm64 agent-relay-darwin-x64 agent-relay-linux-x64 agent-relay-linux-arm64; do
# Check uncompressed
if [ -f "release-binaries/$BINARY" ]; then
echo "✓ $BINARY"
else
echo "✗ MISSING: $BINARY"
MISSING=1
fi
# Check compressed
if [ -f "release-binaries/${BINARY}.gz" ]; then
echo "✓ ${BINARY}.gz"
else
echo "⚠ MISSING: ${BINARY}.gz (compressed version)"
# Don't fail on missing .gz - uncompressed is fallback
fi
done
# Check relay-acp binaries (for Zed editor)
for BINARY in relay-acp-darwin-arm64 relay-acp-darwin-x64 relay-acp-linux-x64 relay-acp-linux-arm64; do
if [ -f "release-binaries/$BINARY" ]; then
echo "✓ $BINARY"
else
echo "⚠ MISSING: $BINARY (Zed ACP bridge)"
# Don't fail on missing - acp-bridge is optional
fi
done
if [ $MISSING -eq 1 ]; then
echo ""
echo "ERROR: Some required binaries are missing!"
exit 1
fi
echo ""
echo "All required binaries present."
- name: Commit and tag
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
NEW_VERSION="${{ needs.build.outputs.new_version }}"
git add package.json package-lock.json packages/*/package.json
if ! git diff --staged --quiet; then
git commit -m "chore(release): v${NEW_VERSION}"
git push origin HEAD:main
fi
git tag -a "v${NEW_VERSION}" -m "Release v${NEW_VERSION}"
git push origin "v${NEW_VERSION}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.build.outputs.new_version }}
name: v${{ needs.build.outputs.new_version }}
body: |
## agent-relay v${{ needs.build.outputs.new_version }}