param( [string]$Version = "1.0.0.7", [string]$TargetAbi = "10.11.11.0", [string]$RepoRawBase = "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies/raw/branch/main" ) $ErrorActionPreference = "Stop" $root = Split-Path -Parent $PSScriptRoot Set-Location $root $guid = "11c08950-c4bb-484d-89ff-205b3724416b" $pluginName = "Request" $zipFileName = "Jellyfin.Plugin.Request_$Version.zip" $releaseDir = Join-Path $root "release" $stageDir = Join-Path $releaseDir "stage" $dllPath = Join-Path $root "Jellyfin.Plugin.Request\bin\Release\net9.0\Jellyfin.Plugin.Request.dll" $zipPath = Join-Path $releaseDir $zipFileName $manifestPath = Join-Path $root "manifest.json" $timestamp = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ") $changelog = "Fix request submit errors with clearer validation and ApiClient base URL" Write-Host "Building plugin..." dotnet build (Join-Path $root "Jellyfin.Plugin.Request.sln") -c Release if (-not (Test-Path $dllPath)) { throw "DLL not found at $dllPath" } New-Item -ItemType Directory -Force -Path $releaseDir | Out-Null if (Test-Path $stageDir) { Remove-Item $stageDir -Recurse -Force } New-Item -ItemType Directory -Force -Path $stageDir | Out-Null $meta = [ordered]@{ guid = $guid name = $pluginName description = "Adds a Request tab to Jellyfin Web so users can search TMDB and submit movie and TV requests into a local queue for administrators to review." overview = "Request movies and TV shows from a local admin review queue" owner = "Michael-A-Sloan" category = "General" version = $Version changelog = $changelog targetAbi = $TargetAbi framework = "net9.0" timestamp = $timestamp } $utf8NoBom = New-Object System.Text.UTF8Encoding $false $metaJson = $meta | ConvertTo-Json -Depth 5 [System.IO.File]::WriteAllText((Join-Path $stageDir "meta.json"), $metaJson, $utf8NoBom) Copy-Item $dllPath -Destination (Join-Path $stageDir "Jellyfin.Plugin.Request.dll") $tempZip = Join-Path $releaseDir ("tmp_" + [guid]::NewGuid().ToString("N") + ".zip") Compress-Archive -Path (Join-Path $stageDir "*") -DestinationPath $tempZip -Force Remove-Item $stageDir -Recurse -Force if (Test-Path $zipPath) { for ($i = 0; $i -lt 5; $i++) { try { Remove-Item $zipPath -Force -ErrorAction Stop break } catch { Start-Sleep -Milliseconds 300 } } } if (Test-Path $zipPath) { # Last resort: write under a new name and replace via copy bytes. [System.IO.File]::Copy($tempZip, $zipPath, $true) Remove-Item $tempZip -Force } else { Move-Item -Path $tempZip -Destination $zipPath -Force } $checksum = (Get-FileHash -Path $zipPath -Algorithm MD5).Hash.ToUpperInvariant() $sourceUrl = "$RepoRawBase/release/$zipFileName" $versionObj = [ordered]@{ version = $Version changelog = $changelog targetAbi = $TargetAbi sourceUrl = $sourceUrl checksum = $checksum timestamp = $timestamp dependencies = @() } $plugin = [ordered]@{ guid = $guid name = $pluginName description = "Adds a Request tab to Jellyfin Web so users can search TMDB and submit movie and TV requests into a local queue for administrators to review." overview = "Request movies and TV shows from a local admin review queue" owner = "Michael-A-Sloan" category = "General" repositoryUrl = "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies" versions = @($versionObj) } # Jellyfin requires a JSON array root and no UTF-8 BOM. $pluginJson = ($plugin | ConvertTo-Json -Depth 8) $manifestJson = "[" + [Environment]::NewLine + $pluginJson + [Environment]::NewLine + "]" [System.IO.File]::WriteAllText($manifestPath, $manifestJson, $utf8NoBom) Write-Host "Packaged: $zipPath" Write-Host "Checksum: $checksum" Write-Host "Manifest: $manifestPath" Write-Host "Jellyfin repository URL:" Write-Host " $RepoRawBase/manifest.json"