forked from phase-rs/phase
-
Notifications
You must be signed in to change notification settings - Fork 0
783 lines (688 loc) · 31.4 KB
/
Copy pathrelease.yml
File metadata and controls
783 lines (688 loc) · 31.4 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
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
tauri-preflight:
name: Tauri Preflight
# Fast-fail sanity check before paying for the full release matrix. Catches
# the structural class of failures that historically only surfaced 30-45
# minutes into the build-tauri job: malformed JSON, version drift between
# workspace Cargo.toml / tauri.conf.json / package.json (which
# cargo-release-local should keep in sync but won't if the release commit
# was hand-edited), and Rust-side compile errors in phase-tauri (excluded
# from regular CI's clippy/test runs in ci.yml). Linux-only — caught
# 99% of failures historically come from cross-platform-agnostic config or
# generic Rust mistakes, not from platform-specific Tauri internals.
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Verify tag matches workspace + Tauri + package versions
run: |
set -euo pipefail
TAG="${GITHUB_REF#refs/tags/}"
EXPECTED="${TAG#v}"
WORKSPACE_VERSION=$(grep -m1 '^version' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')
TAURI_CONF_VERSION=$(jq -r '.version' client/src-tauri/tauri.conf.json)
PACKAGE_JSON_VERSION=$(jq -r '.version' client/package.json)
fail=0
if [ "$WORKSPACE_VERSION" != "$EXPECTED" ]; then
echo "::error::Workspace Cargo.toml version $WORKSPACE_VERSION does not match tag $TAG"; fail=1
fi
if [ "$TAURI_CONF_VERSION" != "$EXPECTED" ]; then
echo "::error::tauri.conf.json version $TAURI_CONF_VERSION does not match tag $TAG"; fail=1
fi
if [ "$PACKAGE_JSON_VERSION" != "$EXPECTED" ]; then
echo "::error::client/package.json version $PACKAGE_JSON_VERSION does not match tag $TAG"; fail=1
fi
[ "$fail" = "0" ]
- name: Validate Tauri JSON configs
run: |
set -euo pipefail
jq empty client/src-tauri/tauri.conf.json
for f in client/src-tauri/capabilities/*.json; do
jq empty "$f"
done
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache-shared-key: rust-tauri-preflight
- name: Install Linux Tauri build deps
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev
- name: Stub frontend dist for tauri::generate_context!
# `cargo check -p phase-tauri` runs `tauri::generate_context!()` which
# needs `frontendDist` (../dist per tauri.conf.json) to exist. We don't
# need the real frontend bundle for type-checking — a stub is enough.
run: |
mkdir -p client/dist
echo '<!doctype html><html></html>' > client/dist/index.html
- name: Stub phase-server sidecar + bundled resources for tauri-build
# tauri.conf.json declares `externalBin: ["binaries/phase-server"]`
# and `resources: { "../public/card-data.json": "data/card-data.json" }`,
# so tauri-build's resource resolver requires both paths to exist
# at check time. The real sidecar / card-data are produced by the
# build-tauri matrix; for the preflight we only need the paths to
# exist (tauri-build validates existence, not content). Empty
# placeholders are sufficient.
run: |
mkdir -p client/src-tauri/binaries client/public
touch client/src-tauri/binaries/phase-server-x86_64-unknown-linux-gnu
touch client/public/card-data.json
- name: cargo check phase-tauri
# phase-tauri is excluded from the root workspace (client/src-tauri),
# so `-p phase-tauri` from the repo root cannot resolve it. Drive the
# check via the crate's own manifest instead.
run: cargo check --manifest-path client/src-tauri/Cargo.toml
build-wasm:
name: Build WASM + Frontend
needs: [tauri-preflight]
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: wasm32-unknown-unknown
cache-shared-key: rust-wasm
- uses: taiki-e/install-action@v2
with:
tool: wasm-bindgen-cli@0.2.114
- name: Cache binaryen
id: binaryen-cache
uses: actions/cache@v4
with:
path: binaryen-version_123
key: binaryen-123-x86_64-linux
- name: Install binaryen
if: steps.binaryen-cache.outputs.cache-hit != 'true'
run: curl -L https://github.com/WebAssembly/binaryen/releases/download/version_123/binaryen-version_123-x86_64-linux.tar.gz | tar xz
- name: Add binaryen to PATH
run: echo "$PWD/binaryen-version_123/bin" >> $GITHUB_PATH
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
cache-dependency-path: client/pnpm-lock.yaml
- name: Set cache keys
id: cache-keys
run: echo "week=$(date +%Y-W%V)" >> "$GITHUB_OUTPUT"
- name: Cache MTGJSON data
id: mtgjson-cache
uses: actions/cache@v4
with:
path: data/mtgjson
key: mtgjson-${{ steps.cache-keys.outputs.week }}
restore-keys: mtgjson-
- name: Download MTGJSON data
if: steps.mtgjson-cache.outputs.cache-hit != 'true'
run: |
mkdir -p data/mtgjson
curl -fSL -o data/mtgjson/AtomicCards.json "https://mtgjson.com/api/v5/AtomicCards.json"
- name: Generate card data and coverage report
# Single source of truth: gen-card-data.sh produces all 7 public JSON
# files. Deploy and release must use the same generator the local
# workflow does — no YAML reimplementation.
run: |
mkdir -p data
./scripts/gen-card-data.sh
# gen-card-data.sh mirrors card-data.json + coverage-data.json into
# data/ itself, so downstream steps can read from data/ uniformly.
- name: Download draft set data
# fetch-draft-sets.sh needs SetList.json (produced by gen-card-data.sh).
# Per-set files land in data/mtgjson/sets/ which is covered by the
# mtgjson cache — subsequent runs skip already-downloaded sets.
run: ./scripts/fetch-draft-sets.sh
- name: Generate draft pools
# Reads data/mtgjson/sets/*.json → writes client/public/draft-pools.json.
# Included in data-files.json manifest so it's uploaded to R2 and
# stripped from the Pages dist automatically.
run: cargo run --release --bin draft-pool-gen
- name: Validate card-data against engine schema
# Deploy gate — refuse to ship card-data the current engine cannot parse.
run: cargo run --release --bin card-data-validate -- client/public/card-data.json
- name: Compute content-addressed card-data filename
id: card-data-hash
# Pin this WASM bundle to its own card-data forever via an immutable
# `card-data-<hash>.json` URL baked into the JS bundle. Old browser
# caches keep resolving their old hash even after a new release.
run: |
HASH=$(sha256sum client/public/card-data.json | awk '{print substr($1, 1, 16)}')
echo "hash=$HASH" >> "$GITHUB_OUTPUT"
echo "filename=card-data-$HASH.json" >> "$GITHUB_OUTPUT"
cp client/public/card-data.json "client/public/card-data-$HASH.json"
- name: Generate Scryfall data
run: |
./scripts/gen-scryfall-images.sh
./scripts/gen-scryfall-sets.sh
./scripts/gen-scryfall-printings.sh
- name: Run semantic audit
# Produces data/semantic-audit.json with structured findings for cards
# that parse without `Unimplemented` markers but disagree semantically
# with their Oracle text. Release uploads use data-files.json as the
# single source of truth, so every manifest entry must exist before R2
# upload begins.
# Pass data/ explicitly — gen-card-data.sh mirrors card-data.json into
# data/ so this matches deploy.yml and avoids relying on client/public.
run: cargo semantic-audit data/
- name: Stamp shared card_data_hash on coverage + audit JSONs
# Both files are uploaded to R2 as separate PUTs with no transactional
# guarantee. Embedding the same card_data_hash in both lets downstream
# consumers verify they're reading a consistent snapshot.
env:
CARD_DATA_HASH: ${{ steps.card-data-hash.outputs.hash }}
run: |
jq --arg h "$CARD_DATA_HASH" '. + {card_data_hash: $h}' data/semantic-audit.json > client/public/semantic-audit.json
jq --arg h "$CARD_DATA_HASH" '. + {card_data_hash: $h}' client/public/coverage-data.json > client/public/coverage-data.json.tmp
mv client/public/coverage-data.json.tmp client/public/coverage-data.json
- name: Upload Scryfall image lookup artifact
uses: actions/upload-artifact@v4
with:
name: scryfall-data
path: client/public/scryfall-data.json
if-no-files-found: error
retention-days: 1
- name: Build WASM
run: ./scripts/build-wasm.sh release
- name: Build frontend
env:
# Standardized data URL config — see vite.config.ts. DATA_BASE_URL is
# the directory holding every shared JSON. CARD_DATA_URL pins the
# WASM bundle to its content-addressed card-data forever.
DATA_BASE_URL: "https://pub-fc5b5c2c6e774356ae3e730bb0326394.r2.dev"
CARD_DATA_URL: "https://pub-fc5b5c2c6e774356ae3e730bb0326394.r2.dev/${{ steps.card-data-hash.outputs.filename }}"
AUDIO_BASE_URL: "https://pub-fc5b5c2c6e774356ae3e730bb0326394.r2.dev/audio"
run: |
cd client
pnpm install --frozen-lockfile
pnpm build
- name: Upload data to R2
# Single source of truth: data-files.json at the repo root drives this
# loop, the verify step below, and vite.config.ts URL defines.
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CARD_DATA_FILENAME: ${{ steps.card-data-hash.outputs.filename }}
run: |
# Content-addressed card-data: immutable, year-long cache.
npx wrangler r2 object put "phase-rs-data/$CARD_DATA_FILENAME" --file "client/public/$CARD_DATA_FILENAME" --remote --content-type application/json --cache-control "public, max-age=31536000, immutable"
# Mutable shared JSONs. Loop over the manifest.
while IFS= read -r f; do
if [ ! -f "client/public/$f" ]; then
echo "::error::Expected data file client/public/$f was not generated"
exit 1
fi
npx wrangler r2 object put "phase-rs-data/$f" --file "client/public/$f" --remote --content-type application/json --cache-control "public, max-age=60, must-revalidate"
done < <(jq -r '.[]' data-files.json)
- name: Verify R2 uploads landed
env:
CARD_DATA_FILENAME: ${{ steps.card-data-hash.outputs.filename }}
run: |
BASE="https://pub-fc5b5c2c6e774356ae3e730bb0326394.r2.dev"
fail=0
check() {
local f="$1"
local status
status=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/$f")
if [ "$status" != "200" ]; then
echo "::error::R2 upload verification failed: $BASE/$f returned $status"
fail=1
else
echo "Verified $BASE/$f ($status)"
fi
}
check "$CARD_DATA_FILENAME"
while IFS= read -r f; do check "$f"; done < <(jq -r '.[]' data-files.json)
[ "$fail" = "0" ]
- name: Remove R2-hosted data files from dist (Pages ships only the shell)
# Single source of truth: data-files.json lists every JSON the frontend
# fetches from R2. The same manifest drives the R2 upload loop above —
# this step is its inverse, stripping those files from the Pages
# bundle so we never double-ship bytes. Adding a new data file is
# now one line in data-files.json and nothing else.
#
# Separately handled:
# - card-data.json (non-manifest; kept in public/ for Tauri + server
# bundles + local dev, but never deployed to Pages)
# - card-data-<16hex>.json[.br] (content-addressed, lives on R2;
# glob matches only 16-hex suffixes, cannot match the 4-char
# `meta` suffix). This replaces the previous `find -regex` which
# used GNU find's default "emacs" regex flavor where `?` is a
# literal — so `\(\.br\)?` matched nothing and the 80 MiB hashed
# file slipped through, exceeding Pages' 25 MiB per-file cap.
shell: bash
run: |
shopt -s nullglob
while IFS= read -r f; do
rm -f "client/dist/$f" "client/dist/$f.br"
done < <(jq -r '.[]' data-files.json)
rm -f client/dist/card-data.json client/dist/card-data.json.br \
client/dist/card-data-????????????????.json \
client/dist/card-data-????????????????.json.br
- name: Upload frontend artifact
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: client/dist
retention-days: 90
- name: Upload card data artifact
uses: actions/upload-artifact@v4
with:
name: card-data
path: client/public/card-data.json
retention-days: 1
deploy-production:
name: Deploy Production (Cloudflare Pages)
needs: [build-wasm]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
name: frontend-dist
path: dist
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy dist --project-name=phase-rs --commit-dirty=true
build-server:
name: Build Server (${{ matrix.os }})
needs: [tauri-preflight, build-wasm]
runs-on: ${{ matrix.runner }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
- os: linux
runner: ubuntu-latest
triple: x86_64-unknown-linux-musl
artifact: phase-server-linux-x86_64
archive_ext: tar.gz
- os: macos
runner: macos-latest
triple: aarch64-apple-darwin
artifact: phase-server-macos-arm64
archive_ext: tar.gz
- os: windows
runner: windows-latest
triple: x86_64-pc-windows-msvc
artifact: phase-server-windows-x86_64
archive_ext: zip
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache-shared-key: rust-server-${{ matrix.os }}
- name: Install musl tools
if: matrix.triple == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
rustup target add x86_64-unknown-linux-musl
- name: Build phase-server
run: cargo build --profile server-release --bin phase-server --target ${{ matrix.triple }}
- name: Download card data
uses: actions/download-artifact@v4
with:
name: card-data
path: staging/data
- name: Package server archive (Unix)
if: matrix.os != 'windows'
run: |
TAG="${GITHUB_REF#refs/tags/}"
mkdir -p staging
cp "target/${{ matrix.triple }}/server-release/phase-server" staging/
chmod +x staging/phase-server
cd staging
tar czf ../${{ matrix.artifact }}.tar.gz phase-server data/card-data.json
shell: bash
- name: Package server archive (Windows)
if: matrix.os == 'windows'
run: |
$Tag = $env:GITHUB_REF -replace 'refs/tags/',''
Copy-Item "target/${{ matrix.triple }}/server-release/phase-server.exe" "staging/"
Compress-Archive -Path "staging/phase-server.exe","staging/data/card-data.json" -DestinationPath "${{ matrix.artifact }}.zip"
shell: pwsh
- name: Generate checksum (Unix)
if: matrix.os != 'windows'
run: shasum -a 256 ${{ matrix.artifact }}.tar.gz > ${{ matrix.artifact }}.tar.gz.sha256
- name: Generate checksum (Windows)
if: matrix.os == 'windows'
run: |
$hash = (Get-FileHash "${{ matrix.artifact }}.zip" -Algorithm SHA256).Hash.ToLower()
"$hash ${{ matrix.artifact }}.zip" | Out-File -Encoding utf8 "${{ matrix.artifact }}.zip.sha256"
shell: pwsh
- name: Upload server archive
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: |
${{ matrix.artifact }}.${{ matrix.archive_ext }}
${{ matrix.artifact }}.${{ matrix.archive_ext }}.sha256
retention-days: 90
build-tauri:
name: Build Tauri (${{ matrix.os }})
needs: [tauri-preflight, build-wasm]
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- os: linux
runner: ubuntu-latest
artifact: phase-tauri-linux
sidecar_triple: x86_64-unknown-linux-gnu
- os: macos
runner: macos-latest
artifact: phase-tauri-macos
sidecar_triple: aarch64-apple-darwin
- os: windows
runner: windows-latest
artifact: phase-tauri-windows
sidecar_triple: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Check macOS signing secrets
id: macos-signing
if: matrix.os == 'macos'
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
set -euo pipefail
missing=0
for name in APPLE_CERTIFICATE APPLE_CERTIFICATE_PASSWORD APPLE_ID APPLE_PASSWORD APPLE_TEAM_ID; do
if [ -z "${!name:-}" ]; then
echo "::warning::Missing macOS signing secret: ${name}"
missing=1
fi
done
if [ "$missing" -ne 0 ]; then
echo "::warning::Skipping macOS Tauri build — Apple signing secrets not configured. The .dmg requires notarization to avoid Gatekeeper errors."
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
shell: bash
- uses: actions-rust-lang/setup-rust-toolchain@v1
if: steps.macos-signing.outputs.skip != 'true'
with:
target: wasm32-unknown-unknown
cache-shared-key: rust-tauri-${{ matrix.os }}
- uses: taiki-e/install-action@v2
if: steps.macos-signing.outputs.skip != 'true'
with:
tool: wasm-bindgen-cli@0.2.114
- name: Install binaryen (Linux)
if: matrix.os == 'linux'
run: |
curl -L https://github.com/WebAssembly/binaryen/releases/download/version_123/binaryen-version_123-x86_64-linux.tar.gz | tar xz
echo "$PWD/binaryen-version_123/bin" >> $GITHUB_PATH
- name: Install binaryen (macOS)
if: matrix.os == 'macos' && steps.macos-signing.outputs.skip != 'true'
run: brew install binaryen
- name: Install binaryen (Windows)
if: matrix.os == 'windows'
run: |
curl -L -o binaryen.tar.gz https://github.com/WebAssembly/binaryen/releases/download/version_123/binaryen-version_123-x86_64-windows.tar.gz
tar xzf binaryen.tar.gz
echo "$PWD\binaryen-version_123\bin" | Out-File -Append -Encoding utf8 $env:GITHUB_PATH
shell: pwsh
- uses: pnpm/action-setup@v4
if: steps.macos-signing.outputs.skip != 'true'
with:
version: 9
- uses: actions/setup-node@v4
if: steps.macos-signing.outputs.skip != 'true'
with:
node-version: 22
cache: pnpm
cache-dependency-path: client/pnpm-lock.yaml
- name: Install system dependencies (Linux)
if: matrix.os == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf musl-tools
rustup target add x86_64-unknown-linux-musl
- name: Download card data
if: steps.macos-signing.outputs.skip != 'true'
uses: actions/download-artifact@v4
with:
name: card-data
path: client/public
- name: Download Scryfall image lookup data
if: steps.macos-signing.outputs.skip != 'true'
uses: actions/download-artifact@v4
with:
name: scryfall-data
path: client/public
- name: Verify Tauri bundled data files
if: steps.macos-signing.outputs.skip != 'true'
run: |
test -s client/public/card-data.json
test -s client/public/scryfall-data.json
shell: bash
- name: Build phase-server sidecar
if: steps.macos-signing.outputs.skip != 'true'
run: |
if [ "${{ matrix.os }}" = "linux" ]; then
cargo build --profile server-release --bin phase-server --target x86_64-unknown-linux-musl
else
cargo build --profile server-release --bin phase-server
fi
mkdir -p client/src-tauri/binaries
shell: bash
- name: Place sidecar binary (Unix)
if: matrix.os != 'windows' && steps.macos-signing.outputs.skip != 'true'
run: |
if [ "${{ matrix.os }}" = "linux" ]; then
cp target/x86_64-unknown-linux-musl/server-release/phase-server client/src-tauri/binaries/phase-server-${{ matrix.sidecar_triple }}
else
cp target/server-release/phase-server client/src-tauri/binaries/phase-server-${{ matrix.sidecar_triple }}
fi
- name: Place sidecar binary (Windows)
if: matrix.os == 'windows'
run: Copy-Item "target/server-release/phase-server.exe" "client/src-tauri/binaries/phase-server-${{ matrix.sidecar_triple }}.exe"
shell: pwsh
- name: Build WASM for Tauri
if: steps.macos-signing.outputs.skip != 'true'
run: ./scripts/build-wasm.sh release
shell: bash
- name: Install frontend dependencies
if: steps.macos-signing.outputs.skip != 'true'
run: cd client && pnpm install --frozen-lockfile
- name: Build Tauri
if: steps.macos-signing.outputs.skip != 'true'
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
with:
projectPath: client
- name: Stage Tauri artifacts
if: steps.macos-signing.outputs.skip != 'true'
run: |
mkdir -p staging
find client/src-tauri/target/release/bundle \
-maxdepth 2 \
\( -name '*.deb' -o -name '*.AppImage' -o -name '*.AppImage.sig' \
-o -name '*.dmg' -o -name '*.app.tar.gz' -o -name '*.app.tar.gz.sig' \
-o -name '*.exe' -o -name '*.exe.sig' \) \
-exec cp {} staging/ \;
ls -la staging/
shell: bash
- name: Upload Tauri artifact
if: steps.macos-signing.outputs.skip != 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: staging/*
retention-days: 90
deploy-server:
name: Deploy Server (beebs)
needs: [build-server]
runs-on: ubuntu-latest
timeout-minutes: 5
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Download server artifact
uses: actions/download-artifact@v4
with:
name: phase-server-linux-x86_64
path: artifact
- name: Extract archive
run: |
mkdir -p staging
tar xzf artifact/phase-server-linux-x86_64.tar.gz -C staging
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -p 29292 -H ${{ secrets.DEPLOY_HOST_BEEBS }} >> ~/.ssh/known_hosts
- name: Deploy to beebs
run: |
SSH="ssh -p 29292 -i ~/.ssh/deploy_key ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST_BEEBS }}"
SCP="scp -P 29292 -i ~/.ssh/deploy_key"
# Upload binary, card data, and service file (service file ensures --lobby-only flag is applied)
$SCP staging/phase-server staging/data/card-data.json deploy/phase-server.service ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST_BEEBS }}:/tmp/
# Stop, install, start
$SSH "sudo systemctl stop phase-server || true \
&& sudo cp /tmp/phase-server /opt/phase-server/phase-server \
&& sudo chmod +x /opt/phase-server/phase-server \
&& sudo cp /tmp/card-data.json /opt/phase-server/data/card-data.json \
&& sudo cp /tmp/phase-server.service /etc/systemd/system/phase-server.service \
&& sudo systemctl daemon-reload \
&& sudo chown -R phase:phase /opt/phase-server \
&& sudo systemctl start phase-server \
&& rm -f /tmp/phase-server /tmp/card-data.json /tmp/phase-server.service"
echo "Deployed phase-server ${GITHUB_REF#refs/tags/} to beebs"
- name: Verify deployment
run: |
sleep 2
SSH="ssh -p 29292 -i ~/.ssh/deploy_key ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST_BEEBS }}"
$SSH "sudo systemctl is-active phase-server"
release:
name: Create GitHub Release
needs: [build-wasm, build-server, build-tauri]
# Proceed if wasm + server succeeded. build-tauri may have skipped
# matrix entries (e.g. macOS when signing secrets are absent) — the
# release still ships with whatever platforms built successfully.
# The updater manifest and artifact globs gracefully handle missing
# platform artifacts (fail_on_unmatched_files: false).
if: >-
always() &&
needs.build-wasm.result == 'success' &&
needs.build-server.result == 'success' &&
(needs.build-tauri.result == 'success' || needs.build-tauri.result == 'failure')
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate updater manifest
run: |
set -euo pipefail
TAG="${GITHUB_REF#refs/tags/}"
REPO="${GITHUB_REPOSITORY}"
# Read signatures for available platforms (skip missing ones).
# Tauri v2 v3-compatible updater format: the raw installer is the
# updater payload (`.AppImage`, `-setup.exe`, `.app.tar.gz`); each
# has a sibling `.sig`. Set in tauri.conf.json: createUpdaterArtifacts: true.
LINUX_SIG=$(cat artifacts/phase-tauri-linux/*.AppImage.sig 2>/dev/null || echo "")
MACOS_SIG=$(cat artifacts/phase-tauri-macos/*.app.tar.gz.sig 2>/dev/null || echo "")
WINDOWS_SIG=$(cat artifacts/phase-tauri-windows/*-setup.exe.sig 2>/dev/null || echo "")
# Build platforms object with only available platforms
PLATFORMS="{"
SEP=""
if [ -n "$LINUX_SIG" ]; then
PLATFORMS="${PLATFORMS}${SEP}\"linux-x86_64\":{\"signature\":\"${LINUX_SIG}\",\"url\":\"https://github.com/${REPO}/releases/download/${TAG}/Phase_${TAG#v}_amd64.AppImage\"}"
SEP=","
fi
if [ -n "$MACOS_SIG" ]; then
PLATFORMS="${PLATFORMS}${SEP}\"darwin-aarch64\":{\"signature\":\"${MACOS_SIG}\",\"url\":\"https://github.com/${REPO}/releases/download/${TAG}/Phase.app.tar.gz\"}"
SEP=","
fi
if [ -n "$WINDOWS_SIG" ]; then
PLATFORMS="${PLATFORMS}${SEP}\"windows-x86_64\":{\"signature\":\"${WINDOWS_SIG}\",\"url\":\"https://github.com/${REPO}/releases/download/${TAG}/Phase_${TAG#v}_x64-setup.exe\"}"
fi
PLATFORMS="${PLATFORMS}}"
if [ "$PLATFORMS" = "{}" ]; then
echo "::warning::No signed updater artifacts found — skipping update.json"
else
# Tauri's plugin-updater parses `version` through Rust's `semver`
# crate, which rejects a leading `v`. Strip it (URL paths above
# already do this with `${TAG#v}`).
VERSION="${TAG#v}"
echo "{\"version\":\"${VERSION}\",\"notes\":\"Release ${TAG}\",\"pub_date\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"platforms\":${PLATFORMS}}" \
| jq . > artifacts/update.json
fi
- name: Generate changelog
run: |
TAG="${GITHUB_REF#refs/tags/}"
PREV_TAG=$(git describe --tags --abbrev=0 "${TAG}^" 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
RANGE="${PREV_TAG}..${TAG}"
else
RANGE="${TAG}"
fi
cat > changelog.md <<'EOF'
## Downloads
| Platform | File |
|----------|------|
| **Windows** | `Phase_*_x64-setup.exe` |
| **macOS (Apple Silicon)** | `Phase_*_aarch64.dmg` |
| **Linux** | `Phase_*_amd64.AppImage` or `.deb` |
> **macOS note:** If you see "this app is damaged", open Terminal and run: `xattr -cr /Applications/Phase.app`
## Changes
EOF
sed -i 's/^ //' changelog.md
git log --format="- %s" "$RANGE" -- ':!.planning' \
| { grep -v "^- release:" || true; } \
| { grep -v "^- chore: update coverage" || true; } \
>> changelog.md
- name: Create release
uses: softprops/action-gh-release@v2
with:
body_path: changelog.md
fail_on_unmatched_files: false
files: |
artifacts/phase-server-linux-x86_64/*.tar.gz
artifacts/phase-server-linux-x86_64/*.sha256
artifacts/phase-server-macos-arm64/*.tar.gz
artifacts/phase-server-macos-arm64/*.sha256
artifacts/phase-server-windows-x86_64/*.zip
artifacts/phase-server-windows-x86_64/*.sha256
artifacts/phase-tauri-linux/*.deb
artifacts/phase-tauri-linux/*.AppImage
artifacts/phase-tauri-macos/*.dmg
artifacts/phase-tauri-macos/*.app.tar.gz
artifacts/phase-tauri-windows/*.exe
artifacts/update.json