фикс
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
# Copy of D:\TTRPG-Release\publish.ps1 - keep in sync when updating the release folder tool.
|
||||
|
||||
param(
|
||||
[switch]$CheckOnly
|
||||
[switch]$CheckOnly,
|
||||
[switch]$SkipMac
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
@@ -38,6 +39,24 @@ function Write-Warn([string]$text) {
|
||||
Write-Host " [--] $text" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
function Get-YmlVersion([string]$ymlPath) {
|
||||
$content = Get-Content -LiteralPath $ymlPath -Raw -Encoding UTF8
|
||||
$m = [regex]::Match($content, '(?m)^version:\s*(\S+)\s*$')
|
||||
if ($m.Success) {
|
||||
return $m.Groups[1].Value.Trim()
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
function Get-YmlPrimaryPath([string]$ymlPath) {
|
||||
$content = Get-Content -LiteralPath $ymlPath -Raw -Encoding UTF8
|
||||
$m = [regex]::Match($content, '(?m)^path:\s*(\S+)\s*$')
|
||||
if ($m.Success) {
|
||||
return $m.Groups[1].Value.Trim()
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
function Get-YmlReferencedFiles([string]$ymlPath) {
|
||||
$names = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
|
||||
$content = Get-Content -LiteralPath $ymlPath -Raw -Encoding UTF8
|
||||
@@ -47,6 +66,20 @@ function Get-YmlReferencedFiles([string]$ymlPath) {
|
||||
return @($names)
|
||||
}
|
||||
|
||||
function Get-YmlOptionalUrls([string]$ymlPath) {
|
||||
$primary = Get-YmlPrimaryPath $ymlPath
|
||||
$names = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
|
||||
$content = Get-Content -LiteralPath $ymlPath -Raw -Encoding UTF8
|
||||
foreach ($m in [regex]::Matches($content, '(?m)^\s*-\s*url:\s*(\S+)\s*$')) {
|
||||
$name = $m.Groups[1].Value.Trim()
|
||||
if ($primary -and $name.Equals($primary, [StringComparison]::OrdinalIgnoreCase)) {
|
||||
continue
|
||||
}
|
||||
[void]$names.Add($name)
|
||||
}
|
||||
return @($names)
|
||||
}
|
||||
|
||||
function Resolve-ReleaseFile([string]$name) {
|
||||
$direct = Join-Path $ReleaseDir $name
|
||||
if (Test-Path -LiteralPath $direct) {
|
||||
@@ -149,17 +182,50 @@ if ($linuxYmls.Count -eq 0) {
|
||||
|
||||
Write-Title 'macOS (if latest-mac.yml present)'
|
||||
$macYml = Join-Path $ReleaseDir 'latest-mac.yml'
|
||||
if (-not (Test-Path -LiteralPath $macYml)) {
|
||||
if ($SkipMac) {
|
||||
Write-Warn 'macOS skipped (-SkipMac)'
|
||||
} elseif (-not (Test-Path -LiteralPath $macYml)) {
|
||||
Write-Warn 'No latest-mac.yml - skipping macOS'
|
||||
} else {
|
||||
Write-Ok 'latest-mac.yml'
|
||||
[void]$uploadFiles.Add($macYml)
|
||||
foreach ($name in (Get-YmlReferencedFiles $macYml)) {
|
||||
|
||||
$macVersion = Get-YmlVersion $macYml
|
||||
$winYml = Join-Path $ReleaseDir 'latest.yml'
|
||||
$winVersion = $null
|
||||
if (Test-Path -LiteralPath $winYml) {
|
||||
$winVersion = Get-YmlVersion $winYml
|
||||
}
|
||||
if ($macVersion -and $winVersion -and $macVersion -ne $winVersion) {
|
||||
$errors.Add(
|
||||
"macOS: latest-mac.yml is v$macVersion but latest.yml is v$winVersion (stale Mac feed). " +
|
||||
'On Mac run: npm run pack:mac, then copy latest-mac.yml + TTRPGPlayer-*.zip (+ optional *.dmg). ' +
|
||||
'Or publish Win/Linux only: publish.cmd -SkipMac'
|
||||
)
|
||||
}
|
||||
|
||||
$primaryName = Get-YmlPrimaryPath $macYml
|
||||
if (-not $primaryName) {
|
||||
$errors.Add('macOS: latest-mac.yml has no path: entry')
|
||||
} else {
|
||||
$primaryFile = Resolve-ReleaseFile $primaryName
|
||||
if ($null -eq $primaryFile) {
|
||||
$errors.Add(
|
||||
"macOS: missing primary update file $primaryName (path in latest-mac.yml). " +
|
||||
'electron-updater on macOS needs the .zip from pack:mac, not only .dmg. Rebuild on Mac or use -SkipMac.'
|
||||
)
|
||||
} else {
|
||||
Write-Ok "primary update: $($primaryFile.Name)"
|
||||
Add-FileToUploadSet $uploadFiles $primaryFile
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($name in (Get-YmlOptionalUrls $macYml)) {
|
||||
$file = Resolve-ReleaseFile $name
|
||||
if ($null -eq $file) {
|
||||
$errors.Add("macOS: missing file $name (from latest-mac.yml)")
|
||||
$warnings.Add("macOS: optional file missing (not uploaded): $name")
|
||||
} else {
|
||||
Write-Ok $name
|
||||
Write-Ok "optional: $($file.Name)"
|
||||
Add-FileToUploadSet $uploadFiles $file
|
||||
}
|
||||
}
|
||||
@@ -213,4 +279,11 @@ if ($LASTEXITCODE -ne 0) {
|
||||
Write-Title 'Done'
|
||||
Write-Host 'Verify:'
|
||||
Write-Host " ${feedUrl}latest.yml"
|
||||
if (Test-Path -LiteralPath (Join-Path $ReleaseDir 'latest-linux.yml')) {
|
||||
Write-Host " ${feedUrl}latest-linux.yml"
|
||||
}
|
||||
if (Test-Path -LiteralPath (Join-Path $ReleaseDir 'latest-mac.yml')) {
|
||||
Write-Host " ${feedUrl}latest-mac.yml"
|
||||
}
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user