92 lines
3.2 KiB
PowerShell
92 lines
3.2 KiB
PowerShell
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$Project,
|
|
|
|
[string]$Changelog
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$repositoryRoot = Split-Path -Parent $PSScriptRoot
|
|
$projectDirectory = Join-Path $repositoryRoot $Project
|
|
|
|
if (-not (Test-Path -LiteralPath $projectDirectory -PathType Container)) {
|
|
throw "Plugin project directory not found: $projectDirectory"
|
|
}
|
|
|
|
$projectFiles = @(Get-ChildItem -LiteralPath $projectDirectory -Filter '*.csproj' -File)
|
|
if ($projectFiles.Count -ne 1) {
|
|
throw "Expected exactly one project file in $projectDirectory"
|
|
}
|
|
|
|
$projectFile = $projectFiles[0]
|
|
$internalName = [System.IO.Path]::GetFileNameWithoutExtension($projectFile.Name)
|
|
|
|
dotnet build $projectFile.FullName -c Release --no-restore
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Release build failed for $internalName"
|
|
}
|
|
|
|
$packageDirectory = Join-Path $projectDirectory "bin\Release\$internalName"
|
|
$manifestPath = Join-Path $packageDirectory "$internalName.json"
|
|
$zipPath = Join-Path $packageDirectory 'latest.zip'
|
|
|
|
if (-not (Test-Path -LiteralPath $manifestPath -PathType Leaf)) {
|
|
throw "Release manifest not found: $manifestPath"
|
|
}
|
|
|
|
if (-not (Test-Path -LiteralPath $zipPath -PathType Leaf)) {
|
|
throw "Release package not found: $zipPath"
|
|
}
|
|
|
|
$manifest = Get-Content -LiteralPath $manifestPath -Raw | ConvertFrom-Json
|
|
$repositoryBaseUrl = 'https://git.bep.moe/verniy/xiv-plugins'
|
|
$downloadUrl = "$repositoryBaseUrl/raw/branch/main/repo/$internalName/latest.zip"
|
|
$destinationDirectory = Join-Path $repositoryRoot "repo\$internalName"
|
|
$pluginMasterPath = Join-Path $repositoryRoot 'pluginmaster.json'
|
|
|
|
New-Item -ItemType Directory -Path $destinationDirectory -Force | Out-Null
|
|
Copy-Item -LiteralPath $zipPath -Destination (Join-Path $destinationDirectory 'latest.zip') -Force
|
|
|
|
$entry = [ordered]@{
|
|
Author = $manifest.Author
|
|
Name = $manifest.Name
|
|
InternalName = $manifest.InternalName
|
|
AssemblyVersion = $manifest.AssemblyVersion
|
|
TestingAssemblyVersion = $null
|
|
Description = $manifest.Description
|
|
Punchline = $manifest.Punchline
|
|
RepoUrl = $manifest.RepoUrl
|
|
ApplicableVersion = $manifest.ApplicableVersion
|
|
DalamudApiLevel = $manifest.DalamudApiLevel
|
|
IsHide = $false
|
|
IsTestingExclusive = $false
|
|
DownloadLinkInstall = $downloadUrl
|
|
DownloadLinkUpdate = $downloadUrl
|
|
LastUpdate = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds().ToString()
|
|
IconUrl = $manifest.IconUrl
|
|
Tags = @($manifest.Tags)
|
|
}
|
|
|
|
if ($Changelog) {
|
|
$entry.Changelog = $Changelog
|
|
} elseif ($manifest.Changelog) {
|
|
$entry.Changelog = $manifest.Changelog
|
|
}
|
|
|
|
$entries = @()
|
|
if (Test-Path -LiteralPath $pluginMasterPath -PathType Leaf) {
|
|
$existing = Get-Content -LiteralPath $pluginMasterPath -Raw | ConvertFrom-Json
|
|
$entries = @($existing | Where-Object { $_.InternalName -ne $internalName })
|
|
}
|
|
|
|
$entries += [PSCustomObject]$entry
|
|
$sortedEntries = @($entries | Sort-Object InternalName)
|
|
$json = ConvertTo-Json -InputObject $sortedEntries -Depth 10
|
|
$utf8 = [System.Text.UTF8Encoding]::new($false)
|
|
[System.IO.File]::WriteAllText($pluginMasterPath, $json + [Environment]::NewLine, $utf8)
|
|
|
|
Write-Output "Published $internalName $($manifest.AssemblyVersion)"
|
|
Write-Output "Repository index: $pluginMasterPath"
|
|
Write-Output "Package: $(Join-Path $destinationDirectory 'latest.zip')"
|