mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 09:19:56 -05:00
194 lines
6.4 KiB
YAML
194 lines
6.4 KiB
YAML
name: Build macOS
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "Version to build (e.g. 0.4.0)"
|
|
required: true
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
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
|
|
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"
|
|
|
|
- name: Stage Suwayomi sidecars
|
|
run: |
|
|
mkdir -p src-tauri/binaries
|
|
|
|
stage_arch() {
|
|
local srcdir="$1"
|
|
local arch="$2"
|
|
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}"
|
|
|
|
cp -r "$srcdir" "$bundle_dest"
|
|
|
|
# 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"
|
|
}
|
|
|
|
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
|
|
|
|
- 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:
|
|
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY || '-' }}
|
|
|
|
- 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 || '-' }}
|
|
|
|
- name: Upload macOS artifacts to release
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
VERSION: ${{ github.event.inputs.version }}
|
|
run: |
|
|
# Wait for the Windows workflow to have created the draft release
|
|
for i in $(seq 1 12); do
|
|
RELEASE_ID=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/Youwes09/Moku/releases" | jq -r '.[] | select(.tag_name == "v'"$VERSION"'") | .id' | head -1)
|
|
if [ -n "$RELEASE_ID" ]; then break; fi
|
|
echo "Waiting for release to exist... attempt $i"
|
|
sleep 15
|
|
done
|
|
|
|
if [ -z "$RELEASE_ID" ]; then
|
|
echo "ERROR: Could not find release for v$VERSION after waiting"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Found release ID: $RELEASE_ID"
|
|
|
|
upload_asset() {
|
|
local file="$1"
|
|
local name="$2"
|
|
echo "Uploading $name..."
|
|
curl -s -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Content-Type: application/octet-stream" --data-binary @"$file" "https://uploads.github.com/repos/Youwes09/Moku/releases/$RELEASE_ID/assets?name=$name"
|
|
}
|
|
|
|
ARM64_DMG=$(find src-tauri/target/aarch64-apple-darwin/release/bundle/dmg -name "*.dmg" | head -1)
|
|
X64_DMG=$(find src-tauri/target/x86_64-apple-darwin/release/bundle/dmg -name "*.dmg" | head -1)
|
|
|
|
[ -n "$ARM64_DMG" ] && upload_asset "$ARM64_DMG" "moku-macos-arm64-${VERSION}.dmg"
|
|
[ -n "$X64_DMG" ] && upload_asset "$X64_DMG" "moku-macos-x64-${VERSION}.dmg" |