-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·133 lines (117 loc) · 4.37 KB
/
build.sh
File metadata and controls
executable file
·133 lines (117 loc) · 4.37 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
#!/usr/bin/env bash
# Build script for Moonfin Jellyfin plugin
# Creates a release ZIP with proper structure for plugin manifest
# Works on Linux, macOS, and Windows (Git Bash/WSL)
set -e
VERSION="${1:-1.8.1.0}"
TARGET_ABI="${2:-10.10.0}"
BUILD_TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
# Get repo root (where this script lives)
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BACKEND_DIR="$ROOT_DIR/backend"
FRONTEND_DIR="$ROOT_DIR/frontend"
WEB_DIST_DIR="$FRONTEND_DIR/dist"
echo "Building Moonfin v${VERSION} for Jellyfin ${TARGET_ABI}..."
echo "Build Time: ${BUILD_TIMESTAMP}"
# Build the web plugin first
if [ -f "$FRONTEND_DIR/build.js" ]; then
echo ""
echo "--- Building web plugin ---"
(cd "$FRONTEND_DIR" && node build.js)
else
echo "Warning: frontend/build.js not found, skipping web build"
fi
# Sync web plugin output into backend embedded resources
if [ -d "$WEB_DIST_DIR" ]; then
echo ""
echo "--- Syncing web files ---"
cp "$WEB_DIST_DIR/plugin.js" "$BACKEND_DIR/Web/plugin.js"
cp "$WEB_DIST_DIR/plugin.css" "$BACKEND_DIR/Web/plugin.css"
echo "Web files synced to backend/Web/"
else
echo "Warning: frontend/dist/ not found, skipping web file sync"
fi
# Build the .NET plugin
echo ""
echo "--- Building server plugin ---"
dotnet build "$BACKEND_DIR/Moonfin.Server.csproj" -c Release
# Create release directory
RELEASE_DIR="$ROOT_DIR/release"
rm -rf "$RELEASE_DIR"
mkdir -p "$RELEASE_DIR"
# Copy DLL to release folder
cp "$BACKEND_DIR/bin/Release/net8.0/Moonfin.Server.dll" "$RELEASE_DIR/"
# Generate meta.json for plugin discovery
PLUGIN_GUID="8c5d0e91-4f2a-4b6d-9e3f-1a7c8d9e0f2b"
TIMESTAMP_ISO=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
cat > "$RELEASE_DIR/meta.json" <<EOF
{
"category": "General",
"changelog": "",
"description": "Moonfin brings a modern TV-style UI to Jellyfin web. Features include: custom navbar, media bar with featured content, Jellyseerr integration, and cross-device settings synchronization.",
"guid": "${PLUGIN_GUID}",
"name": "Moonfin",
"overview": "Custom UI and settings sync for Jellyfin",
"owner": "RadicalMuffinMan",
"targetAbi": "${TARGET_ABI}.0",
"timestamp": "${TIMESTAMP_ISO}",
"version": "${VERSION}",
"status": "Active",
"autoUpdate": true,
"assemblies": ["Moonfin.Server.dll"]
}
EOF
# Create the ZIP file
ZIP_NAME="Moonfin.Server-${VERSION}.zip"
rm -f "$ROOT_DIR/$ZIP_NAME"
cd "$RELEASE_DIR"
zip -r "$ROOT_DIR/$ZIP_NAME" .
cd "$ROOT_DIR"
# Calculate MD5 checksum (cross-platform)
if command -v md5sum &> /dev/null; then
CHECKSUM=$(md5sum "$ZIP_NAME" | awk '{print toupper($1)}')
elif command -v md5 &> /dev/null; then
CHECKSUM=$(md5 -q "$ZIP_NAME" | tr '[:lower:]' '[:upper:]')
elif command -v certutil &> /dev/null; then
# Windows fallback (Git Bash)
CHECKSUM=$(certutil -hashfile "$ZIP_NAME" MD5 2>/dev/null | sed -n '2p' | tr -d ' ' | tr '[:lower:]' '[:upper:]')
else
CHECKSUM="UNABLE_TO_CALCULATE"
fi
# Update manifest.json
MANIFEST_FILE="$ROOT_DIR/manifest.json"
if [ -f "$MANIFEST_FILE" ]; then
# Create timestamp in ISO 8601 format
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%S")
if command -v jq &> /dev/null; then
jq --arg ver "$VERSION" \
--arg abi "${TARGET_ABI}.0" \
--arg sum "$CHECKSUM" \
--arg time "$TIMESTAMP" \
'.[0].versions[0].version = $ver |
.[0].versions[0].targetAbi = $abi |
.[0].versions[0].checksum = $sum |
.[0].versions[0].timestamp = $time' \
"$MANIFEST_FILE" > "${MANIFEST_FILE}.tmp" && mv "${MANIFEST_FILE}.tmp" "$MANIFEST_FILE"
echo "Updated manifest.json with new checksum and version"
else
sed -i.bak -E "s/\"version\": \"[^\"]+\"/\"version\": \"$VERSION\"/" "$MANIFEST_FILE"
sed -i.bak -E "s/\"checksum\": \"[^\"]+\"/\"checksum\": \"$CHECKSUM\"/" "$MANIFEST_FILE"
sed -i.bak -E "s/\"timestamp\": \"[^\"]+\"/\"timestamp\": \"$TIMESTAMP\"/" "$MANIFEST_FILE"
rm -f "${MANIFEST_FILE}.bak"
echo "Updated manifest.json with new checksum and version (using sed)"
fi
fi
# Cleanup
rm -rf "$RELEASE_DIR"
echo ""
echo "========================================="
echo "Build complete!"
echo "Build Time: ${BUILD_TIMESTAMP}"
echo "========================================="
echo "ZIP file: $ZIP_NAME"
echo "MD5 Checksum: $CHECKSUM"
echo "Manifest updated: manifest.json"
echo "========================================="
echo ""
echo "Done!"