claude-prism/scripts/build-linux.sh
delibae 08e54f263d feat: add auto-updater and fix macOS black screen on focus loss (v1.0.1)
- Add tauri-plugin-updater with signed update artifacts
- Add backgroundThrottling: disabled to prevent WKWebView black screen
- Add update check UI with toast notifications (sonner)
- Update build scripts to generate latest.json for GitHub Releases
- Add multi-platform CI workflow (macOS/Linux/Windows) with draft releases
- Bump version to 1.0.1

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 13:16:39 +09:00

104 lines
3 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
# Load env vars (for TAURI_SIGNING_PRIVATE_KEY_PATH)
ENV_FILE="apps/desktop/src-tauri/.env"
if [ -f "$ENV_FILE" ]; then
set -a
source "$ENV_FILE"
set +a
fi
# Require signing key for updater
if [ -z "${TAURI_SIGNING_PRIVATE_KEY:-}" ]; then
echo "Error: TAURI_SIGNING_PRIVATE_KEY is not set"
echo " Local: set it in apps/desktop/src-tauri/.env"
echo " CI: set it as a GitHub Actions secret"
exit 1
fi
TARGET="x86_64-unknown-linux-gnu"
VERSION=$(node -p "require('./package.json').version")
TAG="v${VERSION}"
echo "==> Building ClaudePrism $TAG for Linux ($TARGET)"
# Build
export TECTONIC_DEP_BACKEND=pkg-config
export CXXFLAGS="-std=c++17"
export CFLAGS=""
pnpm --filter @claude-prism/desktop tauri build --target "$TARGET"
BUNDLE_DIR="apps/desktop/src-tauri/target/$TARGET/release/bundle"
# Find outputs
DEB_PATH=$(find "$BUNDLE_DIR/deb" -name '*.deb' 2>/dev/null | head -1)
RPM_PATH=$(find "$BUNDLE_DIR/rpm" -name '*.rpm' 2>/dev/null | head -1)
APPIMAGE_PATH=$(find "$BUNDLE_DIR/appimage" -name '*.AppImage' 2>/dev/null | head -1)
APPIMAGE_SIG=$(find "$BUNDLE_DIR/appimage" -name '*.AppImage.sig' 2>/dev/null | head -1)
ASSETS=()
[ -n "$DEB_PATH" ] && ASSETS+=("$DEB_PATH")
[ -n "$RPM_PATH" ] && ASSETS+=("$RPM_PATH")
[ -n "$APPIMAGE_PATH" ] && ASSETS+=("$APPIMAGE_PATH")
if [ ${#ASSETS[@]} -eq 0 ]; then
echo "Error: No build artifacts found in $BUNDLE_DIR"
exit 1
fi
echo "==> Build artifacts:"
printf " %s\n" "${ASSETS[@]}"
# --- Auto-updater artifacts ---
if [ -n "$APPIMAGE_PATH" ] && [ -n "$APPIMAGE_SIG" ]; then
SIGNATURE=$(cat "$APPIMAGE_SIG")
PUB_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
APPIMAGE_FILENAME=$(basename "$APPIMAGE_PATH")
# Generate latest.json (merge with existing if present)
LATEST_JSON="apps/desktop/src-tauri/target/latest.json"
if [ -f "$LATEST_JSON" ]; then
node -e "
const fs = require('fs');
const data = JSON.parse(fs.readFileSync('$LATEST_JSON', 'utf8'));
data.platforms['linux-x86_64'] = {
signature: \`$SIGNATURE\`,
url: 'https://github.com/delibae/claude-prism/releases/download/$TAG/$APPIMAGE_FILENAME'
};
fs.writeFileSync('$LATEST_JSON', JSON.stringify(data, null, 2));
"
else
cat > "$LATEST_JSON" <<EOF
{
"version": "$VERSION",
"notes": "ClaudePrism $TAG",
"pub_date": "$PUB_DATE",
"platforms": {
"linux-x86_64": {
"signature": "$SIGNATURE",
"url": "https://github.com/delibae/claude-prism/releases/download/$TAG/$APPIMAGE_FILENAME"
}
}
}
EOF
fi
echo "==> Generated latest.json with linux-x86_64"
ASSETS+=("$LATEST_JSON")
else
echo "Warning: AppImage updater artifacts not found, skipping latest.json"
fi
# Upload to GitHub Release
echo "==> Uploading to GitHub Release $TAG"
gh release view "$TAG" --repo delibae/claude-prism >/dev/null 2>&1 || \
gh release create "$TAG" --repo delibae/claude-prism --title "ClaudePrism $TAG" --generate-notes
gh release upload "$TAG" \
--repo delibae/claude-prism \
--clobber \
"${ASSETS[@]}"
echo "==> Done! Linux build uploaded to $TAG"