param( [Parameter(Mandatory)] [string]$ArtifactUrl, [string]$Channel = "stable", [string]$PackagePath = ".\artifacts\OCSentinelClient-win-x64.zip", [string]$OutputPath = ".\artifacts\version.json", [string]$MinUpdaterVersion = "1.0.0" ) $ErrorActionPreference = "Stop" $repoRoot = Split-Path -Parent $PSScriptRoot $projectPath = Join-Path $repoRoot "src\OCSentinelCli\OCSentinelCli.csproj" $packageFullPath = [System.IO.Path]::GetFullPath((Join-Path $repoRoot $PackagePath)) $outputFullPath = [System.IO.Path]::GetFullPath((Join-Path $repoRoot $OutputPath)) if (-not (Test-Path $packageFullPath)) { throw "Package not found: $packageFullPath" } [xml]$projectXml = Get-Content $projectPath $version = $projectXml.Project.PropertyGroup.Version | Select-Object -First 1 if ([string]::IsNullOrWhiteSpace($version)) { $version = "0.0.0" } $sha256 = (Get-FileHash -Path $packageFullPath -Algorithm SHA256).Hash.ToLowerInvariant() $manifest = [ordered]@{ channel = $Channel version = $version publishedAtUtc = (Get-Date).ToUniversalTime().ToString("o") artifactUrl = $ArtifactUrl sha256 = $sha256 minUpdaterVersion = $MinUpdaterVersion } $outputDirectory = Split-Path -Parent $outputFullPath if (-not [string]::IsNullOrWhiteSpace($outputDirectory)) { New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null } $manifest | ConvertTo-Json -Depth 5 | Set-Content -Path $outputFullPath -Encoding UTF8 Write-Host "Release manifest written to $outputFullPath" Write-Host "Version: $version" Write-Host "SHA256: $sha256"