-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild.ps1
More file actions
97 lines (78 loc) · 3.48 KB
/
Copy pathbuild.ps1
File metadata and controls
97 lines (78 loc) · 3.48 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
# Build script for Moonfin Jellyfin plugin
# Creates a release ZIP with proper structure for plugin manifest
# Usage: .\build.ps1 [-Version "1.1.0.0"] [-TargetAbi "10.10.0"]
param(
[string]$Version = "1.9.1.0",
[string]$TargetAbi = "10.10.0"
)
$ErrorActionPreference = "Stop"
$BuildTimestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$RootDir = $PSScriptRoot
$BackendDir = Join-Path $RootDir "backend"
$FrontendDir = Join-Path $RootDir "frontend"
Write-Host "Building Moonfin v${Version} for Jellyfin ${TargetAbi}..."
Write-Host "Build Time: ${BuildTimestamp}"
# Validate expected Flutter web bundle location
$FrontendIndex = Join-Path $FrontendDir "index.html"
if (-not (Test-Path $FrontendIndex)) {
Write-Host ""
Write-Host "Warning: frontend/index.html not found."
Write-Host "Run Mobile-Desktop/build-web-plugin.sh before packaging if you need bundled web assets."
}
# Build the .NET plugin
Write-Host ""
Write-Host "--- Building server plugin ---"
$CsprojPath = Join-Path $BackendDir "Moonfin.Server.csproj"
dotnet build $CsprojPath -c Release
if ($LASTEXITCODE -ne 0) { throw "dotnet build failed" }
# Create release directory
$ReleaseDir = Join-Path $RootDir "release"
if (Test-Path $ReleaseDir) { Remove-Item $ReleaseDir -Recurse -Force }
New-Item -ItemType Directory -Path $ReleaseDir | Out-Null
# Copy DLL to release folder
$DllPath = Join-Path $BackendDir "bin\Release\net8.0\Moonfin.Server.dll"
Copy-Item $DllPath $ReleaseDir
# Bundle Flutter web files next to plugin DLL for local/sideload installs
if (Test-Path $FrontendIndex) {
$ReleaseFrontend = Join-Path $ReleaseDir "frontend"
New-Item -ItemType Directory -Path $ReleaseFrontend -Force | Out-Null
Copy-Item (Join-Path $FrontendDir "*") $ReleaseFrontend -Recurse -Force
$NodeModules = Join-Path $ReleaseFrontend "node_modules"
if (Test-Path $NodeModules) { Remove-Item $NodeModules -Recurse -Force }
$PackageJson = Join-Path $ReleaseFrontend "package.json"
if (Test-Path $PackageJson) { Remove-Item $PackageJson -Force }
$PackageLock = Join-Path $ReleaseFrontend "package-lock.json"
if (Test-Path $PackageLock) { Remove-Item $PackageLock -Force }
}
# Create the ZIP file
$ZipName = "Moonfin.Server-${Version}.zip"
$ZipPath = Join-Path $RootDir $ZipName
if (Test-Path $ZipPath) { Remove-Item $ZipPath -Force }
Compress-Archive -Path (Join-Path $ReleaseDir "*") -DestinationPath $ZipPath
# Calculate MD5 checksum
$Hash = (Get-FileHash $ZipPath -Algorithm MD5).Hash.ToUpper()
# Update manifest.json
$ManifestFile = Join-Path $RootDir "manifest.json"
if (Test-Path $ManifestFile) {
$Timestamp = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss")
$Manifest = Get-Content $ManifestFile -Raw | ConvertFrom-Json
$Manifest[0].versions[0].version = $Version
$Manifest[0].versions[0].targetAbi = "${TargetAbi}.0"
$Manifest[0].versions[0].checksum = $Hash
$Manifest[0].versions[0].timestamp = $Timestamp
$Manifest | ConvertTo-Json -Depth 10 | Set-Content $ManifestFile -Encoding UTF8
Write-Host "Updated manifest.json with new checksum and version"
}
# Cleanup
Remove-Item $ReleaseDir -Recurse -Force
Write-Host ""
Write-Host "========================================="
Write-Host "Build complete!"
Write-Host "Build Time: ${BuildTimestamp}"
Write-Host "========================================="
Write-Host "ZIP file: $ZipName"
Write-Host "MD5 Checksum: $Hash"
Write-Host "Manifest updated: manifest.json"
Write-Host "========================================="
Write-Host ""
Write-Host "Done!"