-
Notifications
You must be signed in to change notification settings - Fork 2
793 lines (708 loc) · 30.7 KB
/
Copy pathrelease.yml
File metadata and controls
793 lines (708 loc) · 30.7 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
name: Release
on:
push:
tags:
- 'v*'
pull_request:
workflow_dispatch:
inputs:
tag:
description: 'Release tag (for example v1.2.3)'
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
sync-version:
name: Sync Version Metadata
if: ${{ (github.ref_type == 'tag' && startsWith(github.ref_name, 'v')) || (github.event.inputs.tag && startsWith(github.event.inputs.tag, 'v')) }}
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
release_tag: ${{ steps.context.outputs.release_tag }}
release_ref: ${{ steps.context.outputs.release_ref }}
release_version: ${{ steps.context.outputs.release_version }}
default_branch: ${{ steps.context.outputs.default_branch }}
changes_detected: ${{ steps.diff.outputs.changed }}
steps:
- name: Generate GitHub App token
id: smg-actions
uses: getsentry/action-github-app-token@v3
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Resolve release context
id: context
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
REF_TYPE: ${{ github.ref_type }}
REF_NAME: ${{ github.ref_name }}
INPUT_TAG: ${{ github.event.inputs.tag || '' }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch || 'master' }}
run: |
tag=""
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
tag="$INPUT_TAG"
elif [[ "$REF_TYPE" == "tag" ]]; then
tag="$REF_NAME"
fi
if [[ -z "$tag" ]]; then
echo "Release tag is required (tag push or workflow input)." >&2
exit 1
fi
version="${tag#v}"
if [[ "$version" == "$tag" ]]; then
version="$tag"
fi
echo "release_tag=$tag" >> "$GITHUB_OUTPUT"
echo "release_ref=refs/tags/$tag" >> "$GITHUB_OUTPUT"
echo "release_version=$version" >> "$GITHUB_OUTPUT"
echo "default_branch=$DEFAULT_BRANCH" >> "$GITHUB_OUTPUT"
echo "RELEASE_TAG=$tag" >> "$GITHUB_ENV"
echo "RELEASE_REF=refs/tags/$tag" >> "$GITHUB_ENV"
echo "RELEASE_VERSION=$version" >> "$GITHUB_ENV"
echo "TARGET_BRANCH=$DEFAULT_BRANCH" >> "$GITHUB_ENV"
- name: Checkout target branch
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ steps.context.outputs.default_branch }}
token: ${{ steps.smg-actions.outputs.token }}
- uses: actions/setup-node@v6
with:
node-version: 20
- name: Update npm metadata
shell: bash
run: |
current=$(node -p "require('./package.json').version")
if [[ "$current" == "$RELEASE_VERSION" ]]; then
echo "package.json already version $current; skipping."
else
npm version "$RELEASE_VERSION" --no-git-tag-version
fi
- name: Update Tauri config
run: |
node <<'NODE'
const fs = require('fs');
const version = process.env.RELEASE_VERSION;
const file = 'src-tauri/tauri.conf.json';
const content = fs.readFileSync(file, 'utf8');
const json = JSON.parse(content);
json.version = version;
fs.writeFileSync(file, JSON.stringify(json, null, 2) + '\n');
NODE
- name: Format version metadata
run: npx --yes prettier@3.6.2 --write package.json package-lock.json src-tauri/tauri.conf.json
- name: Detect changes
id: diff
run: |
if git diff --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit version bump
if: steps.diff.outputs.changed == 'true'
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: 'chore: sync version to ${{ env.RELEASE_TAG }}'
branch: ${{ env.TARGET_BRANCH }}
commit_user_name: marlin-release-bot
commit_user_email: releases@marlin.app
- name: Ensure release tag exists
if: steps.diff.outputs.changed == 'true'
run: |
git fetch --tags --force
git tag -f "$RELEASE_TAG"
git push origin "refs/tags/$RELEASE_TAG" --force
- name: Verify tag matches synced version
if: steps.diff.outputs.changed == 'true'
run: |
if ! git diff --quiet; then
echo "Version sync failed; release tag $RELEASE_TAG still differs." >&2
exit 1
fi
release:
name: Release (${{ matrix.arch }}-${{ matrix.target }})
needs: sync-version
if: ${{ github.event_name != 'pull_request' && needs.sync-version.result == 'success' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# macOS Apple Silicon (M1/M2/M3) - GitHub-hosted
- os: macos-15
target: aarch64-apple-darwin
arch: arm64
rust-targets: aarch64-apple-darwin
smb: true
self_hosted: false
# macOS Intel - GitHub-hosted
- os: macos-15-intel
target: x86_64-apple-darwin
arch: x86_64
rust-targets: x86_64-apple-darwin
smb: false
self_hosted: false
# Linux x86_64
- os: [self-hosted, Linux, X64, medium]
target: x86_64-unknown-linux-gnu
arch: x86_64
rust-targets: x86_64-unknown-linux-gnu
smb: true
self_hosted: true
# Linux arm64 - GitHub-hosted (no self-hosted arm64 runner yet)
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
arch: arm64
rust-targets: aarch64-unknown-linux-gnu
smb: true
self_hosted: false
permissions:
contents: write
env:
RELEASE_TAG: ${{ needs.sync-version.outputs.release_tag || github.ref_name }}
RELEASE_REF: ${{ needs.sync-version.outputs.release_ref || github.ref }}
steps:
- name: Setup persistent cargo target dir (self-hosted)
if: matrix.self_hosted
run: |
# Use persistent target dir outside workspace so it survives between different repo checkouts
echo "CARGO_TARGET_DIR=$HOME/.cache/cargo-target/marlin-${{ matrix.target }}" >> $GITHUB_ENV
mkdir -p "$HOME/.cache/cargo-target/marlin-${{ matrix.target }}"
- name: Validate release tag
shell: bash
run: |
if [ -z "$RELEASE_TAG" ]; then
echo "RELEASE_TAG is not available." >&2
exit 1
fi
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.RELEASE_REF }}
- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
apt_retry() {
for attempt in 1 2 3 4 5 6 7 8 9 10 11 12; do
if sudo DEBIAN_FRONTEND=noninteractive apt-get "$@"; then
return 0
fi
echo "apt-get $* failed on attempt $attempt; retrying in 10s..." >&2
sleep 10
done
sudo DEBIAN_FRONTEND=noninteractive apt-get "$@"
}
apt_retry update
apt_retry install -y \
build-essential \
clang \
curl \
wget \
file \
xdg-utils \
libssl-dev \
libclang-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
pkg-config \
patchelf \
libglib2.0-bin \
libgdk-pixbuf2.0-bin \
desktop-file-utils \
shared-mime-info \
gperf
apt_retry install -y libwebkit2gtk-4.1-dev || apt_retry install -y libwebkit2gtk-4.0-dev
apt_retry install -y libfuse2 || apt_retry install -y libfuse2t64
# Install SMB dependencies if enabled for this target
if [ "${{ matrix.smb }}" = "true" ]; then
apt_retry install -y libsmbclient-dev
fi
- name: Setup Homebrew PATH (macOS self-hosted)
if: runner.os == 'macOS' && matrix.self_hosted
run: |
# Add Homebrew to PATH for Apple Silicon Macs
echo "/opt/homebrew/bin" >> $GITHUB_PATH
echo "/opt/homebrew/sbin" >> $GITHUB_PATH
- name: Install dependencies (macOS)
if: runner.os == 'macOS' && matrix.smb && !matrix.self_hosted
run: |
brew install samba
# Only needed for GitHub-hosted runners (npm cache)
- name: Normalize npm lockfile for caching
if: ${{ !matrix.self_hosted }}
run: |
python3 - <<'PY'
import json
from pathlib import Path
src = Path('package-lock.json')
data = json.loads(src.read_text())
data['version'] = ''
root_pkg = data.get('packages', {}).get('')
if isinstance(root_pkg, dict):
root_pkg['version'] = ''
Path('package-lock.ci.json').write_text(
json.dumps(data, sort_keys=True, separators=(',', ':'))
)
PY
- uses: actions/setup-node@v6
if: ${{ !matrix.self_hosted }}
with:
node-version: 20
cache: 'npm'
cache-dependency-path: package-lock.ci.json
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.rust-targets }}
- name: Cache Rust build artifacts
if: ${{ !matrix.self_hosted }}
uses: Swatinem/rust-cache@v2
with:
workspaces: |
src-tauri -> target
shared-key: release-${{ matrix.target }}
cache-all-crates: true
cache-on-failure: true
# Tauri caching only needed for GitHub-hosted runners
- name: Prepare Tauri cache directory (Linux)
if: runner.os == 'Linux' && !matrix.self_hosted
run: mkdir -p ~/.cache/tauri
- name: Cache Tauri downloads (Linux)
if: runner.os == 'Linux' && !matrix.self_hosted
uses: actions/cache@v5
with:
path: ~/.cache/tauri
key: tauri-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('src-tauri/tauri.conf.json') }}
restore-keys: |
tauri-${{ runner.os }}-${{ matrix.target }}-
tauri-${{ runner.os }}-
- name: Prepare Tauri cache directory (macOS)
if: runner.os == 'macOS' && !matrix.self_hosted
run: mkdir -p ~/Library/Caches/tauri
- name: Cache Tauri downloads (macOS)
if: runner.os == 'macOS' && !matrix.self_hosted
uses: actions/cache@v5
with:
path: ~/Library/Caches/tauri
key: tauri-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('src-tauri/tauri.conf.json') }}
restore-keys: |
tauri-${{ runner.os }}-${{ matrix.target }}-
tauri-${{ runner.os }}-
- name: Install frontend dependencies
run: npm ci
- name: Import Apple Certificate
if: runner.os == 'macOS' && env.APPLE_CERTIFICATE != ''
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
run: |
# Create temporary keychain
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
KEYCHAIN_PASSWORD=$(openssl rand -base64 32)
# Create keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
# Download Apple Developer ID intermediate certificates for chain verification
curl -sL "https://www.apple.com/certificateauthority/DeveloperIDCA.cer" -o $RUNNER_TEMP/DeveloperIDCA.cer
curl -sL "https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer" -o $RUNNER_TEMP/DeveloperIDG2CA.cer
security import $RUNNER_TEMP/DeveloperIDCA.cer -k "$KEYCHAIN_PATH" -T /usr/bin/codesign || true
security import $RUNNER_TEMP/DeveloperIDG2CA.cer -k "$KEYCHAIN_PATH" -T /usr/bin/codesign || true
rm -f $RUNNER_TEMP/DeveloperIDCA.cer $RUNNER_TEMP/DeveloperIDG2CA.cer
# Import signing certificate
echo "$APPLE_CERTIFICATE" | base64 --decode > $RUNNER_TEMP/certificate.p12
security import $RUNNER_TEMP/certificate.p12 -P "$APPLE_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH"
# Add temp keychain to search list, keeping existing valid keychains (other runners may be active on this machine)
EXISTING_KEYCHAINS=$(security list-keychains -d user | tr -d '"' | tr '\n' ' ')
security list-keychain -d user -s "$KEYCHAIN_PATH" $EXISTING_KEYCHAINS
# Allow codesign to access keychain
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
# Clean up certificate file
rm -f $RUNNER_TEMP/certificate.p12
- name: Clean up stale build artifacts (macOS)
if: runner.os == 'macOS'
run: |
# Remove stale bundle artifacts from previous builds to avoid "File exists" errors
TARGET_DIR="${CARGO_TARGET_DIR:-src-tauri/target}"
rm -rf "$TARGET_DIR/${{ matrix.target }}/release/bundle/dmg" || true
rm -rf "$TARGET_DIR/${{ matrix.target }}/release/bundle/macos" || true
- name: Clean up stale build artifacts (Linux)
if: runner.os == 'Linux'
run: |
# Remove stale AppImage bundle to avoid linuxdeploy "Cannot deploy non-existing library" errors
TARGET_DIR="${CARGO_TARGET_DIR:-src-tauri/target}"
rm -rf "$TARGET_DIR/${{ matrix.target }}/release/bundle/appimage" || true
- name: Create SMB sidecar placeholders
run: |
# Create placeholder files for all platforms to satisfy tauri-build
mkdir -p src-tauri/binaries
touch src-tauri/binaries/marlin-smb-x86_64-unknown-linux-gnu
touch src-tauri/binaries/marlin-smb-aarch64-unknown-linux-gnu
touch src-tauri/binaries/marlin-smb-x86_64-apple-darwin
touch src-tauri/binaries/marlin-smb-aarch64-apple-darwin
- name: Build SMB sidecar
if: matrix.smb
run: |
cd src-tauri
cargo build --release --bin marlin-smb --features smb-sidecar --target ${{ matrix.target }}
# Copy sidecar to binaries directory with target triple suffix (Tauri convention)
# This overwrites the placeholder created above
# Use CARGO_TARGET_DIR if set (self-hosted), otherwise default 'target' dir
TARGET_DIR="${CARGO_TARGET_DIR:-target}"
cp "$TARGET_DIR/${{ matrix.target }}/release/marlin-smb" binaries/marlin-smb-${{ matrix.target }}
chmod +x binaries/marlin-smb-${{ matrix.target }}
- name: Codesign SMB sidecar (macOS)
if: matrix.smb && runner.os == 'macOS' && env.APPLE_SIGNING_IDENTITY != '-'
env:
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY || '-' }}
run: |
codesign --force --options runtime --sign "$APPLE_SIGNING_IDENTITY" src-tauri/binaries/marlin-smb-${{ matrix.target }}
- name: Build and publish installers
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
APPIMAGE_EXTRACT_AND_RUN: ${{ runner.os == 'Linux' && '1' || '' }}
TAURI_BUNDLE_DEBUG: '1'
TAURI_LOG: trace
RUST_LOG: tauri_bundler=debug
TAURI_BUNDLE_LINUX_APPIMAGE_ARGS: ${{ runner.os == 'Linux' && '--verbosity=2' || '' }}
# linuxdeploy needs to find libzpl.so when bundling the AppImage
LD_LIBRARY_PATH: ${{ runner.os == 'Linux' && format('{0}/{1}/release', env.CARGO_TARGET_DIR || 'src-tauri/target', matrix.target) || '' }}
# Apple code signing (use ad-hoc signing with '-' if secrets not configured)
# Only pass APPLE_SIGNING_IDENTITY here — omit APPLE_ID/PASSWORD/TEAM_ID
# so Tauri signs without trying to notarize (our DMG step handles notarization)
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY || '-' }}
with:
tagName: ${{ env.RELEASE_TAG }}
releaseName: Marlin ${{ env.RELEASE_TAG }}
releaseBody: |
Automated binaries for Marlin. Download the installer matching your platform.
**macOS users**: Choose `arm64` for Apple Silicon (M1/M2/M3) or `x86_64` for Intel Macs.
releaseDraft: false
prerelease: ${{ startsWith(env.RELEASE_TAG, 'v0.') }}
# macOS: skip DMG (create-dmg uses AppleScript/Finder which requires TCC approval)
# We create a notarized DMG manually in the next step using hdiutil instead
# arm64 Linux (GitHub-hosted): deb only (no AppImage on arm64)
args: >-
--target ${{ matrix.target }}
--verbose
${{ runner.os == 'macOS' && '--bundles app updater' || '' }}
${{ matrix.target == 'aarch64-unknown-linux-gnu' && '--bundles deb' || '' }}
- name: Create DMG (macOS)
if: runner.os == 'macOS'
run: |
set -euo pipefail
TARGET_DIR="${CARGO_TARGET_DIR:-src-tauri/target}"
APP_PATH="$TARGET_DIR/${{ matrix.target }}/release/bundle/macos/Marlin.app"
ARCH="${{ matrix.arch }}"
VERSION="${RELEASE_TAG#v}"
DMG_NAME="Marlin_${VERSION}_${ARCH}.dmg"
DMG_DIR="$TARGET_DIR/${{ matrix.target }}/release/bundle/dmg"
DMG_PATH="$DMG_DIR/$DMG_NAME"
mkdir -p "$DMG_DIR"
# Create a temporary directory with the app and Applications symlink
STAGING=$(mktemp -d)
trap 'rm -rf "$STAGING"' EXIT
cp -R "$APP_PATH" "$STAGING/"
ln -s /Applications "$STAGING/Applications"
# Create DMG using hdiutil (no AppleScript/Finder needed)
# Use arch-specific volume name to avoid "Resource busy" when two
# macOS runners create DMGs on the same machine simultaneously.
created=false
for attempt in 1 2 3; do
rm -f "$DMG_PATH"
hdiutil detach "/Volumes/Marlin-${ARCH}" -force || true
if hdiutil create -volname "Marlin-${ARCH}" -srcfolder "$STAGING" -ov -format UDZO "$DMG_PATH"; then
created=true
break
fi
echo "hdiutil attempt $attempt failed."
if [ "$attempt" -lt 3 ]; then
echo "Retrying in 10s..."
sleep 10
fi
done
if [ "$created" != "true" ]; then
echo "Failed to create $DMG_PATH after 3 attempts." >&2
exit 1
fi
echo "DMG created: $DMG_PATH"
- name: Notarize DMG (macOS)
if: runner.os == 'macOS'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
set -euo pipefail
TARGET_DIR="${CARGO_TARGET_DIR:-src-tauri/target}"
ARCH="${{ matrix.arch }}"
VERSION="${RELEASE_TAG#v}"
DMG_NAME="Marlin_${VERSION}_${ARCH}.dmg"
DMG_PATH="$TARGET_DIR/${{ matrix.target }}/release/bundle/dmg/$DMG_NAME"
if [ -z "${APPLE_ID:-}" ] || [ -z "${APPLE_PASSWORD:-}" ] || [ -z "${APPLE_TEAM_ID:-}" ]; then
echo "Apple notarization credentials are not configured." >&2
exit 1
fi
echo "Notarizing $DMG_NAME..."
xcrun notarytool submit "$DMG_PATH" \
--apple-id "$APPLE_ID" \
--password "$APPLE_PASSWORD" \
--team-id "$APPLE_TEAM_ID" \
--wait
xcrun stapler staple "$DMG_PATH"
echo "DMG notarized and stapled: $DMG_PATH"
- name: Upload DMG to release (macOS)
if: runner.os == 'macOS'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TARGET_DIR="${CARGO_TARGET_DIR:-src-tauri/target}"
ARCH="${{ matrix.arch }}"
VERSION="${RELEASE_TAG#v}"
DMG_NAME="Marlin_${VERSION}_${ARCH}.dmg"
DMG_PATH="$TARGET_DIR/${{ matrix.target }}/release/bundle/dmg/$DMG_NAME"
gh release upload "${{ env.RELEASE_TAG }}" "$DMG_PATH" --clobber
release-dry-run:
name: Dry Run (${{ matrix.arch }}-${{ matrix.target }})
if: ${{ github.event_name == 'pull_request' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# macOS Apple Silicon (M1/M2/M3) - GitHub-hosted
- os: macos-15
target: aarch64-apple-darwin
arch: arm64
rust-targets: aarch64-apple-darwin
smb: true
self_hosted: false
# macOS Intel - GitHub-hosted
- os: macos-15-intel
target: x86_64-apple-darwin
arch: x86_64
rust-targets: x86_64-apple-darwin
smb: false
self_hosted: false
# Linux x86_64
- os: [self-hosted, Linux, X64, medium]
target: x86_64-unknown-linux-gnu
arch: x86_64
rust-targets: x86_64-unknown-linux-gnu
smb: true
self_hosted: true
# Linux arm64 - GitHub-hosted (no self-hosted arm64 runner yet)
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
arch: arm64
rust-targets: aarch64-unknown-linux-gnu
smb: true
self_hosted: false
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup persistent cargo target dir (self-hosted)
if: matrix.self_hosted
run: |
# Use persistent target dir outside workspace so it survives between different repo checkouts
echo "CARGO_TARGET_DIR=$HOME/.cache/cargo-target/marlin-${{ matrix.target }}" >> $GITHUB_ENV
mkdir -p "$HOME/.cache/cargo-target/marlin-${{ matrix.target }}"
- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
apt_retry() {
for attempt in 1 2 3 4 5 6 7 8 9 10 11 12; do
if sudo DEBIAN_FRONTEND=noninteractive apt-get "$@"; then
return 0
fi
echo "apt-get $* failed on attempt $attempt; retrying in 10s..." >&2
sleep 10
done
sudo DEBIAN_FRONTEND=noninteractive apt-get "$@"
}
apt_retry update
apt_retry install -y \
build-essential \
clang \
curl \
wget \
file \
xdg-utils \
libssl-dev \
libclang-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
pkg-config \
patchelf \
libglib2.0-bin \
libgdk-pixbuf2.0-bin \
desktop-file-utils \
shared-mime-info \
gperf
apt_retry install -y libwebkit2gtk-4.1-dev || apt_retry install -y libwebkit2gtk-4.0-dev
apt_retry install -y libfuse2 || apt_retry install -y libfuse2t64
# Install SMB dependencies if enabled for this target
if [ "${{ matrix.smb }}" = "true" ]; then
apt_retry install -y libsmbclient-dev
fi
- name: Setup Homebrew PATH (macOS self-hosted)
if: runner.os == 'macOS' && matrix.self_hosted
run: |
# Add Homebrew to PATH for Apple Silicon Macs
echo "/opt/homebrew/bin" >> $GITHUB_PATH
echo "/opt/homebrew/sbin" >> $GITHUB_PATH
- name: Install dependencies (macOS)
if: runner.os == 'macOS' && matrix.smb && !matrix.self_hosted
run: |
brew install samba
# Only needed for GitHub-hosted runners (npm cache)
- name: Normalize npm lockfile for caching
if: ${{ !matrix.self_hosted }}
run: |
python3 - <<'PY'
import json
from pathlib import Path
src = Path('package-lock.json')
data = json.loads(src.read_text())
data['version'] = ''
root_pkg = data.get('packages', {}).get('')
if isinstance(root_pkg, dict):
root_pkg['version'] = ''
Path('package-lock.ci.json').write_text(
json.dumps(data, sort_keys=True, separators=(',', ':'))
)
PY
- uses: actions/setup-node@v6
if: ${{ !matrix.self_hosted }}
with:
node-version: 20
cache: 'npm'
cache-dependency-path: package-lock.ci.json
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.rust-targets }}
- name: Cache Rust build artifacts
if: ${{ !matrix.self_hosted }}
uses: Swatinem/rust-cache@v2
with:
workspaces: |
src-tauri -> target
shared-key: release-${{ matrix.target }}
cache-all-crates: true
cache-on-failure: true
# Tauri caching only needed for GitHub-hosted runners
- name: Prepare Tauri cache directory (Linux)
if: runner.os == 'Linux' && !matrix.self_hosted
run: mkdir -p ~/.cache/tauri
- name: Cache Tauri downloads (Linux)
if: runner.os == 'Linux' && !matrix.self_hosted
uses: actions/cache@v5
with:
path: ~/.cache/tauri
key: tauri-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('src-tauri/tauri.conf.json') }}
restore-keys: |
tauri-${{ runner.os }}-${{ matrix.target }}-
tauri-${{ runner.os }}-
- name: Prepare Tauri cache directory (macOS)
if: runner.os == 'macOS' && !matrix.self_hosted
run: mkdir -p ~/Library/Caches/tauri
- name: Cache Tauri downloads (macOS)
if: runner.os == 'macOS' && !matrix.self_hosted
uses: actions/cache@v5
with:
path: ~/Library/Caches/tauri
key: tauri-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('src-tauri/tauri.conf.json') }}
restore-keys: |
tauri-${{ runner.os }}-${{ matrix.target }}-
tauri-${{ runner.os }}-
- name: Install frontend dependencies
run: npm ci
- name: Clean up stale build artifacts (macOS)
if: runner.os == 'macOS'
run: |
# Remove stale bundle artifacts from previous builds to avoid "File exists" errors
TARGET_DIR="${CARGO_TARGET_DIR:-src-tauri/target}"
rm -rf "$TARGET_DIR/${{ matrix.target }}/release/bundle/dmg" || true
rm -rf "$TARGET_DIR/${{ matrix.target }}/release/bundle/macos" || true
- name: Clean up stale build artifacts (Linux)
if: runner.os == 'Linux'
run: |
# Remove stale AppImage bundle to avoid linuxdeploy "Cannot deploy non-existing library" errors
TARGET_DIR="${CARGO_TARGET_DIR:-src-tauri/target}"
rm -rf "$TARGET_DIR/${{ matrix.target }}/release/bundle/appimage" || true
- name: Create SMB sidecar placeholders
run: |
# Create placeholder files for all platforms to satisfy tauri-build
mkdir -p src-tauri/binaries
touch src-tauri/binaries/marlin-smb-x86_64-unknown-linux-gnu
touch src-tauri/binaries/marlin-smb-aarch64-unknown-linux-gnu
touch src-tauri/binaries/marlin-smb-x86_64-apple-darwin
touch src-tauri/binaries/marlin-smb-aarch64-apple-darwin
- name: Build SMB sidecar
if: matrix.smb
run: |
cd src-tauri
cargo build --release --bin marlin-smb --features smb-sidecar --target ${{ matrix.target }}
# Copy sidecar to binaries directory with target triple suffix (Tauri convention)
# This overwrites the placeholder created above
# Use CARGO_TARGET_DIR if set (self-hosted), otherwise default 'target' dir
TARGET_DIR="${CARGO_TARGET_DIR:-target}"
cp "$TARGET_DIR/${{ matrix.target }}/release/marlin-smb" binaries/marlin-smb-${{ matrix.target }}
chmod +x binaries/marlin-smb-${{ matrix.target }}
- name: Build Tauri bundle
run: |
set -euxo pipefail
npm run tauri build -- --ci --target ${{ matrix.target }} --verbose ${{ runner.os == 'macOS' && '--bundles app updater' || '' }} ${{ matrix.target == 'aarch64-unknown-linux-gnu' && '--bundles deb' || '' }}
env:
APPIMAGE_EXTRACT_AND_RUN: ${{ runner.os == 'Linux' && '1' || '0' }}
TAURI_BUNDLE_DEBUG: '1'
TAURI_LOG: trace
RUST_LOG: tauri_bundler=debug
TAURI_BUNDLE_LINUX_APPIMAGE_ARGS: ${{ runner.os == 'Linux' && '--verbosity=2' || '' }}
# linuxdeploy needs to find libzpl.so when bundling the AppImage
LD_LIBRARY_PATH: ${{ runner.os == 'Linux' && format('{0}/{1}/release', env.CARGO_TARGET_DIR || 'src-tauri/target', matrix.target) || '' }}
- name: Dump linuxdeploy diagnostics
if: failure() && runner.os == 'Linux'
run: |
set -euxo pipefail
echo "Listing tauri cache directory" >&2
ls -R ~/.cache/tauri | head -n 200 || true
echo "Inspecting extracted linuxdeploy payloads" >&2
find ~/.cache/tauri -maxdepth 2 -type d -name 'squashfs-root' -print || true
echo "Searching for linuxdeploy logs" >&2
find ~/.cache/tauri -type f -name '*.log' -print -exec tail -n +1 {} + || true
target_dir="src-tauri/target/${{ matrix.target }}/release"
appdir="$target_dir/bundle/appimage/Marlin.AppDir"
case "${{ matrix.target }}" in
*x86_64*) linuxdeploy_pattern="linuxdeploy-x86_64.AppImage" ;;
*aarch64*|*arm64*) linuxdeploy_pattern="linuxdeploy-aarch64.AppImage" ;;
*) linuxdeploy_pattern="linuxdeploy-*.AppImage" ;;
esac
shopt -s nullglob
linuxdeploy_candidates=(~/.cache/tauri/${linuxdeploy_pattern})
shopt -u nullglob
if [ ${#linuxdeploy_candidates[@]} -gt 0 ] && [ -d "$appdir" ]; then
linuxdeploy_path="${linuxdeploy_candidates[0]}"
echo "Re-running linuxdeploy with DEBUG=1 for additional context" >&2
set +e
DEBUG=1 "$linuxdeploy_path" --appimage-extract-and-run --verbosity 3 --appdir "$GITHUB_WORKSPACE/$appdir" --plugin gtk --output appimage
replay_status=$?
echo "linuxdeploy replay exited with status $replay_status" >&2
set -e
fi