From 06a9e71a90b0809d318525ecc5c9ccca749e2de3 Mon Sep 17 00:00:00 2001 From: Youwes09 Date: Mon, 23 Mar 2026 11:53:55 -0500 Subject: [PATCH] Fix: MacOS Workflow YAML Error --- .github/workflows/build-macos.yml | 74 ++----------------------- src-tauri/binaries/suwayomi-launcher.sh | 47 ++++++++++++++++ 2 files changed, 52 insertions(+), 69 deletions(-) create mode 100755 src-tauri/binaries/suwayomi-launcher.sh diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 804309e..c79848e 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -96,23 +96,13 @@ jobs: "c7590aeb645dd7135a05b9f3ea1fee384a4abeb465c0b3638d5b738d20dfe174" \ "suwayomi-x64" - # Stage the suwayomi-bundle directory for each arch. - # The Rust code on macOS looks for a sidecar named - # suwayomi-server-{arch}-apple-darwin in resource_dir, and calls it - # with no args — so the sidecar must be a self-contained executable, - # not a shell .command script. - # - # We use jre/bin/java as the sidecar and patch lib.rs behaviour via a - # wrapper script that sets the correct relative paths and passes -jar. - # See: the sidecar IS the wrapper script below, which is fully self- - # contained and uses $0 to find its own location. - name: Stage Suwayomi sidecars run: | mkdir -p src-tauri/binaries stage_arch() { - local srcdir="$1" # e.g. suwayomi-arm64 - local arch="$2" # e.g. aarch64-apple-darwin + local srcdir="$1" + local arch="$2" local sidecar="src-tauri/binaries/suwayomi-server-${arch}" local bundle_dest="src-tauri/binaries/suwayomi-bundle-${arch}" @@ -132,63 +122,11 @@ jobs: echo "${arch}: jar=${JAR} java=${JAVA}" - # Copy the full bundle so Resources/binaries/suwayomi-bundle-{arch} - # is available at runtime via resource_dir. cp -r "$srcdir" "$bundle_dest" - # Write a self-contained launcher script as the Tauri sidecar. - # At runtime Tauri places it in Moku.app/Contents/MacOS/ (for - # externalBin) or Contents/Resources/ (for resources). We resolve - # the bundle relative to the script's own location. - cat > "$sidecar" << 'SCRIPT' -#!/bin/sh -# Moku — Suwayomi launcher sidecar for macOS -# Tauri calls this script directly (no args from Rust side). -# The rootDir JVM flag is prepended by spawn_server in lib.rs. -set -e -DIR="$(cd "$(dirname "$0")" && pwd)" - -# When running from inside the .app bundle the sidecar lives in -# Contents/MacOS/; the bundle is in Contents/Resources/. -# Walk up to find the bundle directory. -find_bundle() { - local base="$1" - for candidate in \ - "${base}/suwayomi-bundle" \ - "${base}/../Resources/suwayomi-bundle" \ - "${base}/../Resources/binaries/suwayomi-bundle" - do - if [ -f "${candidate}/Suwayomi-Server.jar" ]; then - echo "$candidate" - return 0 - fi - done - return 1 -} - -BUNDLE=$(find_bundle "$DIR") || { - echo "[sidecar] ERROR: cannot locate suwayomi-bundle relative to $DIR" >&2 - exit 1 -} - -JAVA="${BUNDLE}/jre/bin/java" -JAR="${BUNDLE}/Suwayomi-Server.jar" - -if [ ! -x "$JAVA" ]; then - echo "[sidecar] ERROR: java not found at $JAVA" >&2 - exit 1 -fi -if [ ! -f "$JAR" ]; then - echo "[sidecar] ERROR: jar not found at $JAR" >&2 - exit 1 -fi - -exec "$JAVA" \ - -Djava.awt.headless=true \ - "$@" \ - -jar "$JAR" -SCRIPT - + # The launcher script is committed at src-tauri/binaries/suwayomi-launcher.sh + # to avoid embedding a heredoc in YAML (which breaks GitHub Actions parsing). + cp src-tauri/binaries/suwayomi-launcher.sh "$sidecar" chmod +x "$sidecar" echo "Staged sidecar: $sidecar" } @@ -245,5 +183,3 @@ SCRIPT name: moku-macos-x64-${{ github.event.inputs.version }} path: src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/*.dmg retention-days: 7 - - diff --git a/src-tauri/binaries/suwayomi-launcher.sh b/src-tauri/binaries/suwayomi-launcher.sh new file mode 100755 index 0000000..6282337 --- /dev/null +++ b/src-tauri/binaries/suwayomi-launcher.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# Moku — Suwayomi launcher sidecar for macOS. +# Tauri calls this script directly; the rootDir JVM flag is prepended by +# spawn_server in lib.rs as the first element of invocation.args. +set -e + +DIR="$(cd "$(dirname "$0")" && pwd)" + +# When running from inside the .app bundle the sidecar lives in +# Contents/MacOS/; the bundle is in Contents/Resources/. +# Walk up to find the bundle directory. +find_bundle() { + local base="$1" + for candidate in \ + "${base}/suwayomi-bundle" \ + "${base}/../Resources/suwayomi-bundle" \ + "${base}/../Resources/binaries/suwayomi-bundle" + do + if [ -f "${candidate}/Suwayomi-Server.jar" ]; then + echo "$candidate" + return 0 + fi + done + return 1 +} + +BUNDLE=$(find_bundle "$DIR") || { + echo "[sidecar] ERROR: cannot locate suwayomi-bundle relative to $DIR" >&2 + exit 1 +} + +JAVA="${BUNDLE}/jre/bin/java" +JAR="${BUNDLE}/Suwayomi-Server.jar" + +if [ ! -x "$JAVA" ]; then + echo "[sidecar] ERROR: java not found at $JAVA" >&2 + exit 1 +fi +if [ ! -f "$JAR" ]; then + echo "[sidecar] ERROR: jar not found at $JAR" >&2 + exit 1 +fi + +exec "$JAVA" \ + -Djava.awt.headless=true \ + "$@" \ + -jar "$JAR"