name: Build macOS on: workflow_dispatch: inputs: version: description: "Version to build (e.g. 0.4.0)" required: true jobs: frontend: name: Build frontend runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 with: version: latest - uses: actions/setup-node@v4 with: node-version: 22 cache: pnpm - name: Install dependencies run: pnpm install --frozen-lockfile - name: Build run: pnpm build - name: Upload dist uses: actions/upload-artifact@v4 with: name: frontend-dist path: dist/ retention-days: 1 tauri: name: Tauri (macOS) needs: frontend runs-on: macos-latest permissions: contents: write steps: - uses: actions/checkout@v4 - name: Download frontend dist uses: actions/download-artifact@v4 with: name: frontend-dist path: dist/ - name: Install Rust uses: dtolnay/rust-toolchain@stable with: targets: aarch64-apple-darwin,x86_64-apple-darwin - name: Rust cache uses: Swatinem/rust-cache@v2 with: workspaces: src-tauri - uses: pnpm/action-setup@v4 with: version: latest - uses: actions/setup-node@v4 with: node-version: 22 cache: pnpm - name: Install JS dependencies run: pnpm install --frozen-lockfile - name: Download Suwayomi binaries run: | download_suwayomi() { local asset="$1" sha="$2" outdir="$3" curl -fsSL \ "https://github.com/Suwayomi/Suwayomi-Server/releases/download/v2.1.1867/${asset}" \ -o "${outdir}.tar.gz" echo "${sha} ${outdir}.tar.gz" | shasum -a 256 -c - mkdir -p "${outdir}" tar -xzf "${outdir}.tar.gz" -C "${outdir}" --strip-components=1 } download_suwayomi \ "Suwayomi-Server-v2.1.1867-macOS-arm64.tar.gz" \ "c80abdbba29f7895e9556c6c9481368557d5f930b5f69bcb30639ba498925f3c" \ "suwayomi-arm64" download_suwayomi \ "Suwayomi-Server-v2.1.1867-macOS-x64.tar.gz" \ "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 sidecar="src-tauri/binaries/suwayomi-server-${arch}" local bundle_dest="src-tauri/binaries/suwayomi-bundle-${arch}" JAR=$(find "$srcdir" -name "Suwayomi-Server.jar" | head -1) JAVA=$(find "$srcdir" -path "*/jre/bin/java" | head -1) if [ -z "$JAR" ]; then echo "ERROR: Suwayomi-Server.jar not found in $srcdir" find "$srcdir" -type f | head -30 exit 1 fi if [ -z "$JAVA" ]; then echo "ERROR: jre/bin/java not found in $srcdir" find "$srcdir" -type f | head -30 exit 1 fi 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 chmod +x "$sidecar" echo "Staged sidecar: $sidecar" } stage_arch suwayomi-arm64 aarch64-apple-darwin stage_arch suwayomi-x64 x86_64-apple-darwin - name: Patch tauri.conf.json for CI run: | sed -i '' 's/"beforeBuildCommand": "pnpm build"/"beforeBuildCommand": ""/' src-tauri/tauri.conf.json # ── aarch64 build ────────────────────────────────────────────────────── - name: Swap bundle for aarch64 run: | rm -rf src-tauri/binaries/suwayomi-bundle cp -r src-tauri/binaries/suwayomi-bundle-aarch64-apple-darwin \ src-tauri/binaries/suwayomi-bundle - name: Build Tauri app (aarch64) run: pnpm tauri build --target aarch64-apple-darwin --config src-tauri/tauri.macos.conf.json env: # Ad-hoc signing ("-") ships without a Developer ID. # Gatekeeper will quarantine the app on other Macs — users must run: # xattr -rd com.apple.quarantine Moku.app # To fix this properly, set APPLE_SIGNING_IDENTITY to your # "Developer ID Application: ..." cert name and add # APPLE_CERTIFICATE / APPLE_CERTIFICATE_PASSWORD / APPLE_ID / # APPLE_TEAM_ID / APPLE_APP_SPECIFIC_PASSWORD secrets for notarisation. APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY || '-' }} # ── x86_64 build ─────────────────────────────────────────────────────── - name: Swap bundle for x86_64 run: | rm -rf src-tauri/binaries/suwayomi-bundle cp -r src-tauri/binaries/suwayomi-bundle-x86_64-apple-darwin \ src-tauri/binaries/suwayomi-bundle - name: Build Tauri app (x86_64) run: pnpm tauri build --target x86_64-apple-darwin --config src-tauri/tauri.macos.conf.json env: APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY || '-' }} # ── upload artifacts ─────────────────────────────────────────────────── - name: Upload arm64 .dmg uses: actions/upload-artifact@v4 with: name: moku-macos-arm64-${{ github.event.inputs.version }} path: src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/*.dmg retention-days: 7 - name: Upload x64 .dmg uses: actions/upload-artifact@v4 with: name: moku-macos-x64-${{ github.event.inputs.version }} path: src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/*.dmg retention-days: 7