2 Commits

Author SHA1 Message Date
83dcb77425 Stage package sources in temp directory
All checks were successful
Build Mod Package / build (push) Successful in 6s
2026-04-08 00:58:51 +03:00
e67c7e6093 Add fallback package source strategies to build script
Some checks failed
Build Mod Package / build (push) Failing after 5s
2026-04-08 00:56:22 +03:00

View File

@@ -21,7 +21,8 @@ $workspacePath = [System.IO.Path]::GetFullPath($Workspace)
$modsPath = Join-Path $workspacePath "Mods"
$modPath = Join-Path $modsPath $ModFolder
$buildPath = Join-Path $workspacePath "build"
$stagingPath = Join-Path $workspacePath "build-stage"
$stagingRoot = Join-Path $env:TEMP "bg3-dnd55e-russian-localization-stage"
$stagingPath = Join-Path $stagingRoot "build-stage"
$packagePath = Join-Path $buildPath $PackageName
$tempPackagePath = Join-Path $env:TEMP $PackageName
$archiveName = $ArchiveBaseName
@@ -59,13 +60,55 @@ foreach ($path in @($stagingPath, $tempPackagePath, $packagePath, $zipPath, $inf
}
}
New-Item -ItemType Directory -Path $stagingPath | Out-Null
if (Test-Path -LiteralPath $stagingRoot) {
Remove-Item -LiteralPath $stagingRoot -Recurse -Force
}
New-Item -ItemType Directory -Path $stagingPath -Force | Out-Null
Copy-Item -LiteralPath $modsPath -Destination $stagingPath -Recurse
& $DivinePath -a create-package -g bg3 -s $stagingPath -d $tempPackagePath
Write-Host "[build.ps1] Staged source tree:"
Get-ChildItem -Recurse $stagingPath | Select-Object FullName, Length | Format-Table -AutoSize
if (-not (Test-Path -LiteralPath $tempPackagePath)) {
throw "Temporary package was not created."
if (Test-Path -LiteralPath $tempPackagePath) {
Remove-Item -LiteralPath $tempPackagePath -Force
}
$packageAttempts = @(
[ordered]@{ Name = "staging-root"; Source = $stagingPath },
[ordered]@{ Name = "mods-root"; Source = $modsPath },
[ordered]@{ Name = "workspace-root"; Source = $workspacePath }
)
$successfulAttempt = $null
foreach ($attempt in $packageAttempts) {
if (Test-Path -LiteralPath $tempPackagePath) {
Remove-Item -LiteralPath $tempPackagePath -Force
}
Write-Host "[build.ps1] Trying Divine source '$($attempt.Name)': $($attempt.Source)"
& $DivinePath -a create-package -g bg3 -s $attempt.Source -d $tempPackagePath
if (-not (Test-Path -LiteralPath $tempPackagePath)) {
Write-Host "[build.ps1] No package created for attempt '$($attempt.Name)'."
continue
}
$attemptPackage = Get-Item -LiteralPath $tempPackagePath
Write-Host "[build.ps1] Attempt '$($attempt.Name)' produced $($attemptPackage.Length) bytes."
if ($attemptPackage.Length -ge 1024) {
$successfulAttempt = $attempt
break
}
}
if (-not $successfulAttempt) {
$lastSize = "missing"
if (Test-Path -LiteralPath $tempPackagePath) {
$lastSize = (Get-Item -LiteralPath $tempPackagePath).Length
}
throw "Package looks invalid after all attempts. Last output '$tempPackagePath' size: $lastSize bytes."
}
Move-Item -LiteralPath $tempPackagePath -Destination $packagePath
@@ -75,9 +118,7 @@ if (-not (Test-Path -LiteralPath $packagePath)) {
}
$packageFile = Get-Item -LiteralPath $packagePath
if ($packageFile.Length -lt 1024) {
throw "Package looks invalid: '$packagePath' is only $($packageFile.Length) bytes."
}
Write-Host "[build.ps1] Using package from attempt '$($successfulAttempt.Name)'."
$packageMd5 = (Get-FileHash -LiteralPath $packagePath -Algorithm MD5).Hash.ToLowerInvariant()
$createdAt = (Get-Date).ToString("o")