Repository navigation
1312 lines (1129 loc) · 57.1 KB
/
Copy pathprerelease.yml
File metadata and controls
1312 lines (1129 loc) · 57.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
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: Prerelease
on:
push:
branches: [next]
tags: ["v*-rc.*", "v*-next.*"]
workflow_dispatch:
permissions:
contents: write
env:
GITHUB_ENVIRONMENT: staging
jobs:
build:
environment: staging
# Run on pushes to next branch or prerelease tags
if: github.ref == 'refs/heads/next' || startsWith(github.ref, 'refs/tags/v') && (contains(github.ref, '-rc.') || contains(github.ref, '-next.'))
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
cgo: "0"
name: mcpproxy-linux-amd64
archive_format: tar.gz
- os: ubuntu-latest
goos: linux
goarch: arm64
cgo: "0"
name: mcpproxy-linux-arm64
archive_format: tar.gz
- os: windows-latest
goos: windows
goarch: amd64
cgo: "1"
name: mcpproxy-windows-amd64.exe
archive_format: zip
- os: windows-latest
goos: windows
goarch: arm64
cgo: "1"
name: mcpproxy-windows-arm64.exe
archive_format: zip
- os: macos-15
goos: darwin
goarch: amd64
cgo: "1"
name: mcpproxy-darwin-amd64
archive_format: tar.gz
- os: macos-15
goos: darwin
goarch: arm64
cgo: "1"
name: mcpproxy-darwin-arm64
archive_format: tar.gz
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "1.26"
- name: Cache Go modules and build
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/AppData/Local/go-build
key: ${{ runner.os }}-go-1.26-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-1.26-
- name: Download dependencies
run: go mod download
- name: Setup Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22'
- name: Install frontend dependencies
run: cd frontend && npm ci
- name: Build frontend
run: cd frontend && npm run build
- name: Copy frontend dist to embed location
shell: bash
run: |
rm -rf web/frontend
mkdir -p web/frontend
cp -r frontend/dist web/frontend/
- name: Import Code-Signing Certificates (macOS)
if: matrix.goos == 'darwin'
run: |
set -euo pipefail
echo "📦 Preparing isolated keychain for code signing"
UNIQUE_ID="${{ matrix.goos }}-${{ matrix.goarch }}-$$-$(date +%s)"
TEMP_KEYCHAIN="mcpproxy-build-${UNIQUE_ID}.keychain"
security create-keychain -p "temp123" "$TEMP_KEYCHAIN"
security list-keychains -s "$TEMP_KEYCHAIN" ~/Library/Keychains/login.keychain-db /Library/Keychains/System.keychain
security unlock-keychain -p "temp123" "$TEMP_KEYCHAIN"
security set-keychain-settings -t 3600 -l "$TEMP_KEYCHAIN"
if [ -z "${{ secrets.APPLE_DEVELOPER_ID_CERT }}" ] || [ -z "${{ secrets.APPLE_DEVELOPER_ID_CERT_PASSWORD }}" ]; then
echo "❌ APPLE_DEVELOPER_ID_CERT and APPLE_DEVELOPER_ID_CERT_PASSWORD secrets are required"
exit 1
fi
echo "${{ secrets.APPLE_DEVELOPER_ID_CERT }}" | base64 -d > developer-id.p12
security import developer-id.p12 \
-k "$TEMP_KEYCHAIN" \
-P "${{ secrets.APPLE_DEVELOPER_ID_CERT_PASSWORD }}" \
-T /usr/bin/codesign \
-T /usr/bin/productbuild \
-T /usr/bin/productsign \
-T /usr/bin/security
rm -f developer-id.p12
echo "🔍 Checking for separate Developer ID Installer certificate"
INSTALLER_ID=$(security find-identity -v -p basic "$TEMP_KEYCHAIN" | grep "Developer ID Installer" || true)
if [ -z "$INSTALLER_ID" ]; then
if [ -z "${{ secrets.APPLE_DEVELOPER_ID_INSTALLER_CERT }}" ] || [ -z "${{ secrets.APPLE_DEVELOPER_ID_INSTALLER_CERT_PASSWORD }}" ]; then
echo "❌ Developer ID Installer identity not found in APPLE_DEVELOPER_ID_CERT"
echo " Provide APPLE_DEVELOPER_ID_INSTALLER_CERT and password secrets"
exit 1
fi
echo "Importing dedicated Developer ID Installer certificate"
echo "${{ secrets.APPLE_DEVELOPER_ID_INSTALLER_CERT }}" | base64 -d > developer-id-installer.p12
security import developer-id-installer.p12 \
-k "$TEMP_KEYCHAIN" \
-P "${{ secrets.APPLE_DEVELOPER_ID_INSTALLER_CERT_PASSWORD }}" \
-T /usr/bin/productsign \
-T /usr/bin/productbuild \
-T /usr/bin/codesign \
-T /usr/bin/security
rm -f developer-id-installer.p12
fi
security set-key-partition-list -S apple-tool:,apple: -s -k "temp123" "$TEMP_KEYCHAIN"
APP_CERT_IDENTITY=$(security find-identity -v -p codesigning "$TEMP_KEYCHAIN" | grep "Developer ID Application" | head -1 | grep -o '"[^"]*"' | tr -d '"')
PKG_CERT_IDENTITY=$(security find-identity -v -p basic "$TEMP_KEYCHAIN" | grep "Developer ID Installer" | head -1 | grep -o '"[^"]*"' | tr -d '"')
if [ -z "$APP_CERT_IDENTITY" ]; then
echo "❌ Developer ID Application identity not found after import"
exit 1
fi
if [ -z "$PKG_CERT_IDENTITY" ]; then
echo "❌ Developer ID Installer identity not found after import"
exit 1
fi
echo "✅ Using Developer ID Application: $APP_CERT_IDENTITY"
echo "✅ Using Developer ID Installer: $PKG_CERT_IDENTITY"
echo "APP_CERT_IDENTITY=$APP_CERT_IDENTITY" >> "$GITHUB_ENV"
echo "PKG_CERT_IDENTITY=$PKG_CERT_IDENTITY" >> "$GITHUB_ENV"
echo "$TEMP_KEYCHAIN" > .keychain_name
echo "=== Available signing identities in temporary keychain ==="
security find-identity -v "$TEMP_KEYCHAIN"
echo "✅ Certificate import completed"
- name: Build binary and create archives
shell: bash
env:
CGO_ENABLED: ${{ matrix.cgo }}
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
# ✅ Force minimum supported macOS version for compatibility (13.0 for Swift tray app)
MACOSX_DEPLOYMENT_TARGET: "13.0"
# Defensive CGO flags to ensure proper deployment target
CGO_CFLAGS: "-mmacosx-version-min=13.0"
CGO_LDFLAGS: "-mmacosx-version-min=13.0"
# Spec 092 FR-011/FR-014: pin the Sparkle EdDSA PUBLIC key so RC builds
# can consume the beta feed. Same secret as the stable pipeline — one
# keypair, two channels; the CHANNEL is what separates them, not the key.
# No secret ⇒ scripts/build-swift-app.sh leaves the placeholder and the
# updater stays off.
SPARKLE_PUBLIC_ED_KEY: ${{ secrets.SPARKLE_ED_PUBLIC_KEY }}
SPARKLE_FEED_URL: ${{ vars.SPARKLE_FEED_URL }}
run: |
# For prerelease, determine version differently
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
# Get last tag on any branch for base version
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
COMMIT_HASH=$(git rev-parse --short HEAD)
VERSION="${LAST_TAG}-next.${COMMIT_HASH}"
fi
echo "Building version: ${VERSION}"
# -X paths must use the full module path (go.mod: github.com/smart-mcp-proxy/mcpproxy-go);
# a wrong path is silently ignored and the binary reports "development".
LDFLAGS="-s -w -X main.version=${VERSION} -X github.com/smart-mcp-proxy/mcpproxy-go/internal/httpapi.buildVersion=${VERSION}"
# Determine clean binary name
if [ "${{ matrix.goos }}" = "windows" ]; then
CLEAN_BINARY="mcpproxy.exe"
else
CLEAN_BINARY="mcpproxy"
fi
# Create clean core binary for archive
#
# NOTE (Spec 092 FR-014/FR-020): unlike release.yml, the RC archive is
# deliberately NOT stamped with updatecheck.buildChannel=tarball. The
# verification half of that prerequisite is now met — the release job
# below publishes checksums.txt and its cosign bundle, so an RC IS
# installable by a stable tarball user who opted into prereleases —
# but stamping the RC archive itself is a separate decision about
# whether a binary extracted from a prerelease should self-update, and
# it is not made here.
go build -ldflags "${LDFLAGS}" -o ${CLEAN_BINARY} ./cmd/mcpproxy
# Build tray binary for the platforms with GUI support, matching
# release.yml. Windows matters here even though the RC tray reaches
# users through the Inno installer (built further below, AFTER the
# archives): that installed tray self-updates by downloading this
# job's .zip and extracting the mcpproxy-tray.exe member by name, so
# a zip built without it leaves every Windows RC tray unable to
# update. As in release.yml, the archived tray is unsigned — SignPath
# signs installers, not archive members.
if [ "${{ matrix.goos }}" = "darwin" ]; then
echo "Building mcpproxy-tray for macOS..."
go build -ldflags "${LDFLAGS}" -o mcpproxy-tray ./cmd/mcpproxy-tray
elif [ "${{ matrix.goos }}" = "windows" ]; then
echo "Building mcpproxy-tray.exe for Windows..."
# -H windowsgui matches scripts/build-windows-installer.ps1: the
# tray must link as a GUI executable or it opens a console window
# on launch, and a self-update installs this copy over the
# installer's.
go build -ldflags "${LDFLAGS} -H windowsgui" -o mcpproxy-tray.exe ./cmd/mcpproxy-tray
fi
# Build Swift tray app (macOS only — replaces Go tray in .app bundle for DMG/PKG)
if [ "${{ matrix.goos }}" = "darwin" ]; then
chmod +x scripts/build-swift-app.sh
OUTPUT_DIR="$(pwd)/swift-build"
mkdir -p "$OUTPUT_DIR"
./scripts/build-swift-app.sh "${VERSION}" "${{ matrix.goarch }}" "$OUTPUT_DIR"
SWIFT_APP="$OUTPUT_DIR/MCPProxy.app"
if [ -d "$SWIFT_APP" ]; then
echo "SWIFT_APP_PATH=$SWIFT_APP" >> $GITHUB_ENV
else
echo "❌ Swift app build failed"
exit 1
fi
fi
# Code sign macOS binaries
if [ "${{ matrix.goos }}" = "darwin" ]; then
echo "Code signing macOS binary..."
# Debug: List all available certificates
echo "Available certificates:"
security find-identity -v -p codesigning
# Find the Developer ID certificate identity
CERT_IDENTITY=$(security find-identity -v -p codesigning | grep "Developer ID Application" | head -1 | grep -o '"[^"]*"' | tr -d '"')
# Verify we found a valid certificate
if [ -n "${CERT_IDENTITY}" ]; then
echo "✅ Found Developer ID certificate: ${CERT_IDENTITY}"
else
echo "❌ No Developer ID certificate found, using team ID as fallback"
CERT_IDENTITY="${{ secrets.APPLE_TEAM_ID }}"
echo "⚠️ Using fallback identity: ${CERT_IDENTITY}"
fi
# Validate entitlements file formatting (Apple's recommendation)
echo "=== Validating entitlements file ==="
if [ -f "scripts/entitlements.plist" ]; then
echo "Validating entitlements formatting with plutil..."
if plutil -lint scripts/entitlements.plist; then
echo "✅ Entitlements file is properly formatted"
else
echo "❌ Entitlements file has formatting issues"
exit 1
fi
# Convert to XML format if needed (Apple's recommendation)
plutil -convert xml1 scripts/entitlements.plist
echo "✅ Entitlements converted to XML format"
else
echo "⚠️ No entitlements file found"
fi
# Sign both binaries with proper Developer ID certificate, hardened runtime, and timestamp
echo "=== Signing binaries with hardened runtime ==="
# Install GNU coreutils for timeout command (macOS compatibility)
if ! command -v timeout &> /dev/null; then
echo "Installing GNU coreutils for timeout command..."
brew install coreutils
# Use gtimeout from coreutils
TIMEOUT_CMD="gtimeout"
else
TIMEOUT_CMD="timeout"
fi
# Sign core binary
echo "Signing core binary: ${CLEAN_BINARY}"
SIGN_SUCCESS=false
for attempt in 1 2 3; do
echo "Core binary signing attempt $attempt/3..."
# Use timeout command to prevent hanging (max 5 minutes per attempt)
if $TIMEOUT_CMD 300 codesign --force \
--options runtime \
--entitlements scripts/entitlements.plist \
--sign "${CERT_IDENTITY}" \
--timestamp \
${CLEAN_BINARY}; then
SIGN_SUCCESS=true
echo "✅ Core binary signing succeeded on attempt $attempt"
break
else
echo "❌ Core binary signing attempt $attempt failed or timed out"
if [ $attempt -lt 3 ]; then
echo "Retrying in 10 seconds..."
sleep 10
fi
fi
done
if [ "$SIGN_SUCCESS" != "true" ]; then
echo "❌ All core binary signing attempts failed"
exit 1
fi
# Sign tray binary
echo "Signing tray binary: mcpproxy-tray"
TRAY_SIGN_SUCCESS=false
for attempt in 1 2 3; do
echo "Tray binary signing attempt $attempt/3..."
# Use timeout command to prevent hanging (max 5 minutes per attempt)
if $TIMEOUT_CMD 300 codesign --force \
--options runtime \
--entitlements scripts/entitlements.plist \
--sign "${CERT_IDENTITY}" \
--timestamp \
mcpproxy-tray; then
TRAY_SIGN_SUCCESS=true
echo "✅ Tray binary signing succeeded on attempt $attempt"
break
else
echo "❌ Tray binary signing attempt $attempt failed or timed out"
if [ $attempt -lt 3 ]; then
echo "Retrying in 10 seconds..."
sleep 10
fi
fi
done
if [ "$TRAY_SIGN_SUCCESS" != "true" ]; then
echo "❌ All tray binary signing attempts failed"
exit 1
fi
# Verify signing, hardened runtime, and timestamp using Apple's recommended methods
echo "=== Verifying binary signatures (Apple's recommended verification) ==="
# Verify core binary
echo "=== Core binary verification ==="
codesign --verify --verbose ${CLEAN_BINARY}
echo "Core binary basic verification: $?"
# Apple's recommended strict verification for notarization
echo "=== Core binary strict verification (matches notarization requirements) ==="
if codesign -vvv --deep --strict ${CLEAN_BINARY}; then
echo "✅ Core binary strict verification PASSED - ready for notarization"
else
echo "❌ Core binary strict verification FAILED - will not pass notarization"
exit 1
fi
# Verify tray binary
echo "=== Tray binary verification ==="
codesign --verify --verbose mcpproxy-tray
echo "Tray binary basic verification: $?"
# Apple's recommended strict verification for notarization
echo "=== Tray binary strict verification (matches notarization requirements) ==="
if codesign -vvv --deep --strict mcpproxy-tray; then
echo "✅ Tray binary strict verification PASSED - ready for notarization"
else
echo "❌ Tray binary strict verification FAILED - will not pass notarization"
exit 1
fi
# Check for secure timestamp (Apple's recommended check)
echo "=== Checking for secure timestamps ==="
CORE_TIMESTAMP_CHECK=$(codesign -dvv ${CLEAN_BINARY} 2>&1)
if echo "$CORE_TIMESTAMP_CHECK" | grep -q "Timestamp="; then
echo "✅ Core binary secure timestamp present:"
echo "$CORE_TIMESTAMP_CHECK" | grep "Timestamp="
else
echo "❌ No secure timestamp found for core binary"
fi
TRAY_TIMESTAMP_CHECK=$(codesign -dvv mcpproxy-tray 2>&1)
if echo "$TRAY_TIMESTAMP_CHECK" | grep -q "Timestamp="; then
echo "✅ Tray binary secure timestamp present:"
echo "$TRAY_TIMESTAMP_CHECK" | grep "Timestamp="
else
echo "❌ No secure timestamp found for tray binary"
fi
echo "✅ Both binaries signed successfully with hardened runtime and timestamp"
fi
# Create archive with version info - DO NOT create "latest" archives for prereleases
ARCHIVE_BASE="mcpproxy-${VERSION#v}-${{ matrix.goos }}-${{ matrix.goarch }}"
# The tray binary ships alongside the core, exactly as release.yml
# does it. The tray's self-update extracts the mcpproxy-tray member
# from this archive by name and fails closed when it is absent, so an
# RC archive without it leaves every prerelease tray unable to update
# (RC builds track the rc channel by construction — see
# App.includePrereleases in internal/tray/tray.go).
FILES_TO_ARCHIVE="${CLEAN_BINARY}"
if [ "${{ matrix.goos }}" = "windows" ] && [ -f "mcpproxy-tray.exe" ]; then
FILES_TO_ARCHIVE="${FILES_TO_ARCHIVE} mcpproxy-tray.exe"
echo "Including mcpproxy-tray.exe in archive"
elif [ "${{ matrix.goos }}" = "darwin" ] && [ -f "mcpproxy-tray" ]; then
FILES_TO_ARCHIVE="${FILES_TO_ARCHIVE} mcpproxy-tray"
echo "Including mcpproxy-tray in archive"
elif [ "${{ matrix.goos }}" = "darwin" ] || [ "${{ matrix.goos }}" = "windows" ]; then
# Same rule as release.yml: fail rather than ship a core-only
# archive that would strand every tray self-update. Linux has no
# tray and falls through untouched.
echo "::error::no tray binary to archive for ${{ matrix.goos }}; a core-only archive would strand every tray self-update"
exit 1
fi
if [ "${{ matrix.archive_format }}" = "zip" ]; then
# Create only versioned archive (no latest for prereleases)
if [ "${{ matrix.goos }}" = "windows" ]; then
# Use PowerShell Compress-Archive on Windows since zip command isn't available
PS_FILES=$(echo ${FILES_TO_ARCHIVE} | sed 's/ /,/g')
powershell -Command "Compress-Archive -Path ${PS_FILES} -DestinationPath '${ARCHIVE_BASE}.zip'"
else
zip "${ARCHIVE_BASE}.zip" ${FILES_TO_ARCHIVE}
fi
else
# Create only versioned archive (no latest for prereleases)
tar -czf "${ARCHIVE_BASE}.tar.gz" ${FILES_TO_ARCHIVE}
fi
- name: Build Linux .deb and .rpm packages
if: matrix.goos == 'linux'
uses: ./.github/actions/build-linux-packages
with:
goarch: ${{ matrix.goarch }}
- name: Install Inno Setup (Windows)
if: matrix.goos == 'windows'
shell: pwsh
run: |
choco install innosetup -y
# Verify installation
if (Test-Path "C:\Program Files (x86)\Inno Setup 6\ISCC.exe") {
Write-Host "✅ Inno Setup installed successfully"
} else {
Write-Host "❌ Inno Setup installation failed"
exit 1
}
- name: Create Windows installer (Windows - Prerelease)
if: matrix.goos == 'windows'
shell: pwsh
run: |
# For prerelease, version includes commit hash
if ("${{ github.ref }}" -like "refs/tags/*") {
$VERSION = "${{ github.ref_name }}"
} else {
$VERSION = (git describe --tags --always --dirty)
}
$ARCH = "${{ matrix.goarch }}"
Write-Host "Building Windows installer for prerelease version ${VERSION} (${ARCH})"
# Run the build script
.\scripts\build-windows-installer.ps1 -Version $VERSION -Arch $ARCH
# Verify installer was created
$INSTALLER_NAME = "mcpproxy-setup-${VERSION}-${ARCH}.exe"
$INSTALLER_PATH = "dist\${INSTALLER_NAME}"
if (Test-Path $INSTALLER_PATH) {
Write-Host "✅ Windows installer created: ${INSTALLER_NAME}"
$size = (Get-Item $INSTALLER_PATH).Length / 1MB
Write-Host " Size: $([math]::Round($size, 2)) MB"
} else {
Write-Host "❌ Windows installer not found at ${INSTALLER_PATH}"
exit 1
}
- name: Upload Windows installer artifact (Prerelease)
if: matrix.goos == 'windows'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: installer-windows-${{ matrix.goarch }}
path: dist/mcpproxy-setup-*-${{ matrix.goarch }}.exe
- name: Create .icns icon (macOS)
if: matrix.goos == 'darwin'
run: |
chmod +x scripts/create-icns.sh
./scripts/create-icns.sh
- name: Create DMG installer (macOS)
if: matrix.goos == 'darwin'
env:
# Ensure DMG creation also uses correct deployment target (13.0 for Swift tray app)
MACOSX_DEPLOYMENT_TARGET: "13.0"
CGO_CFLAGS: "-mmacosx-version-min=13.0"
CGO_LDFLAGS: "-mmacosx-version-min=13.0"
run: |
# For prerelease, determine version differently (reuse from build step)
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
# Get last tag on any branch for base version
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
COMMIT_HASH=$(git rev-parse --short HEAD)
VERSION="${LAST_TAG}-next.${COMMIT_HASH}"
fi
chmod +x scripts/create-dmg.sh
# Determine binary names
TRAY_BINARY="mcpproxy-tray"
CORE_BINARY="mcpproxy"
# Create DMG with Swift app (preferred) or Go tray binary as fallback
if [ -n "${SWIFT_APP_PATH:-}" ]; then
./scripts/create-dmg.sh "$SWIFT_APP_PATH" ${CORE_BINARY} ${VERSION} ${{ matrix.goarch }}
else
./scripts/create-dmg.sh ${TRAY_BINARY} ${CORE_BINARY} ${VERSION} ${{ matrix.goarch }}
fi
# Sign DMG
DMG_NAME="mcpproxy-${VERSION#v}-darwin-${{ matrix.goarch }}.dmg"
echo "Signing DMG: ${DMG_NAME}"
# Find the Developer ID certificate identity
CERT_IDENTITY=$(security find-identity -v -p codesigning | grep "Developer ID Application" | head -1 | grep -o '"[^"]*"' | tr -d '"')
# Verify we found a valid certificate
if [ -n "${CERT_IDENTITY}" ]; then
echo "✅ Found Developer ID certificate for DMG: ${CERT_IDENTITY}"
else
echo "❌ No Developer ID certificate found for DMG, using team ID as fallback"
CERT_IDENTITY="${{ secrets.APPLE_TEAM_ID }}"
echo "⚠️ Using fallback identity for DMG: ${CERT_IDENTITY}"
fi
# Sign DMG with proper certificate and timestamp
codesign --force \
--sign "${CERT_IDENTITY}" \
--timestamp \
"${DMG_NAME}"
# Verify DMG signing
echo "=== Verifying DMG signature ==="
codesign --verify --verbose "${DMG_NAME}"
echo "DMG verification: $?"
codesign --display --verbose=4 "${DMG_NAME}"
echo "✅ DMG created and signed successfully: ${DMG_NAME}"
- name: Create PKG installer (macOS)
if: matrix.goos == 'darwin'
env:
# Ensure PKG creation also uses correct deployment target (13.0 for Swift tray app)
MACOSX_DEPLOYMENT_TARGET: "13.0"
CGO_CFLAGS: "-mmacosx-version-min=13.0"
CGO_LDFLAGS: "-mmacosx-version-min=13.0"
run: |
# For prerelease, determine version differently (reuse from build step)
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
# Get last tag on any branch for base version
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
COMMIT_HASH=$(git rev-parse --short HEAD)
VERSION="${LAST_TAG}-next.${COMMIT_HASH}"
fi
chmod +x scripts/create-pkg.sh
chmod +x scripts/create-installer-dmg.sh
# Set up certificate environment for PKG creation (reuse from binary signing)
echo "=== Setting up certificate environment for PKG creation ==="
# Debug: List all available certificates for PKG creation
echo "=== Available certificates for PKG creation ==="
echo "Codesigning certificates:"
security find-identity -v -p codesigning || echo "No codesigning certificates found"
echo "Basic certificates:"
security find-identity -v -p basic || echo "No basic certificates found"
echo "All certificates:"
security find-identity -v || echo "No certificates found"
# Prefer identities exported during certificate import, fallback to keychain lookup
APP_CERT_IDENTITY="${APP_CERT_IDENTITY:-}"
PKG_CERT_IDENTITY="${PKG_CERT_IDENTITY:-}"
if [ -z "${APP_CERT_IDENTITY}" ]; then
APP_CERT_IDENTITY=$(security find-identity -v -p codesigning | grep "Developer ID Application" | head -1 | grep -o '"[^"]*"' | tr -d '"')
fi
if [ -z "${PKG_CERT_IDENTITY}" ]; then
PKG_CERT_IDENTITY=$(security find-identity -v -p basic | grep "Developer ID Installer" | head -1 | grep -o '"[^"]*"' | tr -d '"')
fi
if [ -z "${APP_CERT_IDENTITY}" ]; then
echo "❌ Developer ID Application certificate not available in the build keychain"
exit 1
fi
if [ -z "${PKG_CERT_IDENTITY}" ]; then
echo "❌ Developer ID Installer certificate not available in the isolated keychain"
echo " Embed the 'Developer ID Installer' identity in APPLE_DEVELOPER_ID_CERT"
exit 1
fi
echo "✅ Using Developer ID Application certificate: ${APP_CERT_IDENTITY}"
echo "✅ Using Developer ID Installer certificate: ${PKG_CERT_IDENTITY}"
export APP_CERT_IDENTITY
export PKG_CERT_IDENTITY
# Determine binary names
TRAY_BINARY="mcpproxy-tray"
CORE_BINARY="mcpproxy"
# Create PKG installer with Swift app (preferred) or Go tray binary as fallback
echo "Creating signed PKG installer with certificate: ${PKG_CERT_IDENTITY}"
if [ -n "${SWIFT_APP_PATH:-}" ]; then
./scripts/create-pkg.sh "$SWIFT_APP_PATH" ${CORE_BINARY} ${VERSION} ${{ matrix.goarch }}
else
./scripts/create-pkg.sh ${TRAY_BINARY} ${CORE_BINARY} ${VERSION} ${{ matrix.goarch }}
fi
# Create installer DMG containing the PKG
PKG_NAME="mcpproxy-${VERSION#v}-darwin-${{ matrix.goarch }}.pkg"
./scripts/create-installer-dmg.sh ${PKG_NAME} ${VERSION} ${{ matrix.goarch }}
echo "✅ PKG installer and installer DMG created successfully"
- name: Submit for notarization (macOS)
if: matrix.goos == 'darwin'
run: |
set -euo pipefail
# For prerelease, determine version differently (reuse from build step)
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
# Get last tag on any branch for base version
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
COMMIT_HASH=$(git rev-parse --short HEAD)
VERSION="${LAST_TAG}-next.${COMMIT_HASH}"
fi
PKG_NAME="mcpproxy-${VERSION#v}-darwin-${{ matrix.goarch }}.pkg"
INSTALLER_DMG_NAME="mcpproxy-${VERSION#v}-darwin-${{ matrix.goarch }}-installer.dmg"
notarize_and_staple() {
local FILE_NAME="$1"
local FILE_LABEL="$2"
if [ ! -f "${FILE_NAME}" ]; then
echo "❌ ${FILE_LABEL} (${FILE_NAME}) not found"
return 1
fi
echo "Submitting ${FILE_LABEL} for notarization: ${FILE_NAME}"
local SUBMISSION_OUTPUT
if ! SUBMISSION_OUTPUT=$(xcrun notarytool submit "${FILE_NAME}" \
--apple-id "${{ secrets.APPLE_ID_USERNAME }}" \
--password "${{ secrets.APPLE_ID_APP_PASSWORD }}" \
--team-id "${{ secrets.APPLE_TEAM_ID }}" \
--wait \
--output-format json 2>&1); then
echo "❌ ${FILE_LABEL} notarization failed"
echo "Output: ${SUBMISSION_OUTPUT}"
return 1
fi
local SUBMISSION_ID
SUBMISSION_ID=$(echo "${SUBMISSION_OUTPUT}" | jq -r '.id // empty')
local STATUS
STATUS=$(echo "${SUBMISSION_OUTPUT}" | jq -r '.status // empty')
if [ -z "${SUBMISSION_ID}" ] || [ "${SUBMISSION_ID}" = "null" ] || [ "${STATUS}" != "Accepted" ]; then
echo "❌ ${FILE_LABEL} notarization did not succeed"
echo "Response: ${SUBMISSION_OUTPUT}"
return 1
fi
echo "✅ ${FILE_LABEL} notarization accepted (ID: ${SUBMISSION_ID})"
echo "${SUBMISSION_ID}" > "${FILE_NAME}.submission_id"
echo "Stapling notarization ticket to ${FILE_LABEL}"
# Apple ticket delivery (CloudKit) drops connections intermittently
# ("network connection was lost", exit 68); retry with backoff.
for attempt in 1 2 3 4 5; do
xcrun stapler staple "${FILE_NAME}" && break
if [ "$attempt" = 5 ]; then exit 1; fi
echo "stapler staple failed (attempt $attempt), retrying"; sleep $((attempt * 15))
done
for attempt in 1 2 3 4 5; do
xcrun stapler validate "${FILE_NAME}" && break
if [ "$attempt" = 5 ]; then exit 1; fi
echo "stapler validate failed (attempt $attempt), retrying"; sleep $((attempt * 15))
done
}
notarize_and_staple "${PKG_NAME}" "PKG installer"
notarize_and_staple "${INSTALLER_DMG_NAME}" "Installer DMG"
echo "✅ Notarization and stapling complete"
# Spec 092 FR-014 — RC builds get the same enclosure the stable pipeline
# produces. See the identical step in release.yml for why `ditto -c -k
# --sequesterRsrc --keepParent` and why the .app is notarized and stapled
# separately from the PKG. Signing step order is untouched.
#
# Only TAGGED RCs produce an enclosure: this workflow also runs on pushes to
# `next`, and a branch build has no release to attach a feed to.
- name: Build Sparkle enclosure (macOS)
if: matrix.goos == 'darwin' && startsWith(github.ref, 'refs/tags/')
env:
SPARKLE_ED_PRIVATE_KEY: ${{ secrets.SPARKLE_ED_PRIVATE_KEY }}
run: |
set -euo pipefail
mkdir -p sparkle-enclosure
if [ -z "${SPARKLE_ED_PRIVATE_KEY:-}" ]; then
echo "ℹ️ SPARKLE_ED_PRIVATE_KEY is not configured — skipping the Sparkle enclosure."
exit 0
fi
# The enclosure must ship the SAME bundle users run: the DMG staging
# copy that create-dmg.sh signed (core + certs + Developer ID deep
# signature) and exported. SWIFT_APP_PATH is the raw swift-build
# output — no core, not notarization-signed — and must never be
# zipped as an update (it failed notarization and would install a
# coreless app).
APP_SRC="signed-app-${{ matrix.goarch }}/mcpproxy.app"
if [ ! -d "${APP_SRC}" ]; then
echo "❌ signed bundle export missing: ${APP_SRC} (create-dmg.sh exports it)"
exit 1
fi
VERSION=${GITHUB_REF#refs/tags/}
ENCLOSURE="mcpproxy-${VERSION#v}-darwin-${{ matrix.goarch }}.app.zip"
NOTARIZE_ZIP="sparkle-notarize-${{ matrix.goarch }}.zip"
ditto -c -k --sequesterRsrc --keepParent "${APP_SRC}" "${NOTARIZE_ZIP}"
SUBMISSION_OUTPUT=$(xcrun notarytool submit "${NOTARIZE_ZIP}" \
--apple-id "${{ secrets.APPLE_ID_USERNAME }}" \
--password "${{ secrets.APPLE_ID_APP_PASSWORD }}" \
--team-id "${{ secrets.APPLE_TEAM_ID }}" \
--wait \
--output-format json)
STATUS=$(echo "${SUBMISSION_OUTPUT}" | jq -r '.status // empty')
if [ "${STATUS}" != "Accepted" ]; then
echo "❌ App-bundle notarization did not succeed"
echo "Response: ${SUBMISSION_OUTPUT}"
exit 1
fi
# Apple ticket delivery (CloudKit) drops connections intermittently
# ("network connection was lost", exit 68); retry with backoff.
for attempt in 1 2 3 4 5; do
xcrun stapler staple "${APP_SRC}" && break
if [ "$attempt" = 5 ]; then exit 1; fi
echo "stapler staple failed (attempt $attempt), retrying"; sleep $((attempt * 15))
done
for attempt in 1 2 3 4 5; do
xcrun stapler validate "${APP_SRC}" && break
if [ "$attempt" = 5 ]; then exit 1; fi
echo "stapler validate failed (attempt $attempt), retrying"; sleep $((attempt * 15))
done
ditto -c -k --sequesterRsrc --keepParent "${APP_SRC}" "sparkle-enclosure/${ENCLOSURE}"
rm -f "${NOTARIZE_ZIP}"
VERIFY_DIR=$(mktemp -d)
ditto -x -k "sparkle-enclosure/${ENCLOSURE}" "${VERIFY_DIR}"
codesign --verify --deep --strict --verbose=2 "${VERIFY_DIR}/mcpproxy.app"
# Apple ticket delivery (CloudKit) drops connections intermittently
# ("network connection was lost", exit 68); retry with backoff.
for attempt in 1 2 3 4 5; do
xcrun stapler validate "${VERIFY_DIR}/mcpproxy.app" && break
if [ "$attempt" = 5 ]; then exit 1; fi
echo "stapler validate failed (attempt $attempt), retrying"; sleep $((attempt * 15))
done
rm -rf "${VERIFY_DIR}"
echo "✅ Sparkle enclosure ready: ${ENCLOSURE}"
- name: Upload Sparkle enclosure artifact
if: matrix.goos == 'darwin' && startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: sparkle-enclosure-${{ matrix.goarch }}
path: sparkle-enclosure/*
if-no-files-found: ignore
- name: Cleanup isolated keychain (macOS)
if: matrix.goos == 'darwin' && always()
run: |
# Clean up the isolated keychain we created for this worker
if [ -f .keychain_name ]; then
TEMP_KEYCHAIN=$(cat .keychain_name)
echo "Cleaning up keychain: ${TEMP_KEYCHAIN}"
# Remove from search list and delete
security delete-keychain "$TEMP_KEYCHAIN" 2>/dev/null || echo "Keychain already cleaned up"
rm -f .keychain_name
echo "✅ Keychain cleanup completed"
else
echo "No keychain to clean up"
fi
- name: Upload versioned archive artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: versioned-${{ matrix.goos }}-${{ matrix.goarch }}
path: mcpproxy-*-${{ matrix.goos }}-${{ matrix.goarch }}.${{ matrix.archive_format }}
- name: Upload macOS installer DMG
if: matrix.goos == 'darwin'
run: |
set -euo pipefail
# For prerelease, determine version to create exact file names (reuse from build step)
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
# Get last tag on any branch for base version
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
COMMIT_HASH=$(git rev-parse --short HEAD)
VERSION="${LAST_TAG}-next.${COMMIT_HASH}"
fi
INSTALLER_DMG_NAME="mcpproxy-${VERSION#v}-darwin-${{ matrix.goarch }}-installer.dmg"
echo "Looking for files:"
echo " Installer DMG: ${INSTALLER_DMG_NAME}"
if [ ! -f "${INSTALLER_DMG_NAME}" ]; then
echo "❌ Installer DMG not found: ${INSTALLER_DMG_NAME}"
exit 1
fi
mkdir -p installers-artifact
cp "${INSTALLER_DMG_NAME}" installers-artifact/
SUBMISSION_ID_FILE="${INSTALLER_DMG_NAME}.submission_id"
if [ -f "${SUBMISSION_ID_FILE}" ]; then
echo "✅ Found submission ID file: ${SUBMISSION_ID_FILE}"
cp "${SUBMISSION_ID_FILE}" installers-artifact/
else
echo "⚠️ No submission ID file found: ${SUBMISSION_ID_FILE}"
fi
echo "Files to upload:"
ls -la installers-artifact/
- name: Upload macOS installers artifact
if: matrix.goos == 'darwin'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: installers-${{ matrix.goos }}-${{ matrix.goarch }}
path: installers-artifact/*
# Spec 081: release qualification gate (same reusable workflow as release.yml).
# Guarded to prerelease TAG refs only — skipped on `next` branch pushes,
# consistent with the `release` job's own tag condition, so branch CI is not
# burdened with the full gate. A red gate blocks the prerelease publish
# (FR-002); a skipped gate (branch push) skips `release` too (never un-gated).
qa-gate:
uses: ./.github/workflows/release-qa-gate.yml
permissions:
contents: read
if: startsWith(github.ref, 'refs/tags/v') && (contains(github.ref, '-rc.') || contains(github.ref, '-next.'))
release:
needs: [build, qa-gate]
runs-on: ubuntu-latest
environment: staging
permissions:
contents: write
# Spec 092 FR-014: cosign keyless signing takes its identity from the
# GitHub Actions OIDC token. release.yml grants this at the workflow
# level; here only this job needs it.
id-token: write
# Only create releases for tag pushes, not branch pushes
if: startsWith(github.ref, 'refs/tags/v') && (contains(github.ref, '-rc.') || contains(github.ref, '-next.'))
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist
- name: Reorganize files
run: |
VERSION=${GITHUB_REF#refs/tags/}
# Create a flat structure to avoid duplicates
mkdir -p release-files
# Copy archives (tar.gz and zip files) - only versioned, no latest for prereleases.
# The QA gate runs as a reusable workflow of THIS run, so its artifacts land
# in dist/ too; its Playwright HTML report stores traces as
# playwright-report/data/<sha>.zip and must never become a release asset.
find dist -not -path "*/web-ui-sweep-playwright-report/*" \( -name "*.tar.gz" -o -name "*.zip" \) | while read file; do
filename=$(basename "$file")
cp "$file" "release-files/$filename"
done
# Copy Linux .deb and .rpm packages
find dist -path "*/linux-packages-*" \( -name "*.deb" -o -name "*.rpm" \) | while read pkg_file; do
filename=$(basename "$pkg_file")
echo "Found Linux package: $filename"
cp "$pkg_file" "release-files/$filename"
done
# Copy Windows installer files (.exe)
find dist -path "*/installer-windows-*" -name "*.exe" | while read installer_file; do
filename=$(basename "$installer_file")
echo "Found Windows installer: $filename"
cp "$installer_file" "release-files/$filename"
done
# Handle installer files (DMG and PKG) and notarization submissions
mkdir -p pending-notarizations
# Process installer artifacts (only notarized installer DMGs)
find dist -path "*/installers-*" -name "*.dmg" | while read installer_file; do
filename=$(basename "$installer_file")
submission_id_file="${installer_file}.submission_id"
if [ -f "$submission_id_file" ]; then
# File has pending notarization
SUBMISSION_ID=$(cat "$submission_id_file")
# Validate submission ID before creating pending file
if [ -n "$SUBMISSION_ID" ] && [ "$SUBMISSION_ID" != "null" ] && [ ${#SUBMISSION_ID} -gt 10 ]; then
echo "Found valid pending notarization for $filename (ID: $SUBMISSION_ID)"
cp "$installer_file" "release-files/$filename"
# Create pending notarization record
cat > "pending-notarizations/${filename}.pending" << EOF
{
"submission_id": "$SUBMISSION_ID",
"file_name": "$filename",
"version": "$VERSION",
"submitted_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
}