5 Commits

Author SHA1 Message Date
84c9baa2d5 chore: delete build script for BG3 Russian package 2026-04-08 01:30:22 +03:00
a60aa56477 Run CI only for tags and manual dispatch
All checks were successful
Build Mod Package / build (push) Successful in 18s
2026-04-08 01:16:56 +03:00
6d1186b60a Derive mod version from release tag during build
Some checks failed
Build Mod Package / build (push) Failing after 11s
2026-04-08 01:10:17 +03:00
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
3 changed files with 88 additions and 17 deletions

View File

@@ -2,9 +2,6 @@ name: Build Mod Package
on:
push:
branches:
- main
- master
tags:
- "v*"
workflow_dispatch:

View File

@@ -17,11 +17,40 @@ param(
$ErrorActionPreference = "Stop"
function Convert-VersionTagToVersion64 {
param(
[string]$Tag,
[string]$FallbackVersion64
)
if (-not $Tag) {
return [int64]$FallbackVersion64
}
$normalized = $Tag
if ($normalized.StartsWith("v")) {
$normalized = $normalized.Substring(1)
}
if ($normalized -notmatch '^\d+(\.\d+){0,3}$') {
return [int64]$FallbackVersion64
}
$parts = $normalized.Split(".")
$numbers = @(0, 0, 0, 0)
for ($i = 0; $i -lt $parts.Length; $i++) {
$numbers[$i] = [int]$parts[$i]
}
return ([int64]$numbers[0] -shl 55) -bor ([int64]$numbers[1] -shl 47) -bor ([int64]$numbers[2] -shl 31) -bor [int64]$numbers[3]
}
$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
@@ -30,6 +59,7 @@ if ($VersionTag) {
}
$zipPath = Join-Path $buildPath "$archiveName.zip"
$infoJsonPath = Join-Path $buildPath "info.json"
$resolvedVersion64 = Convert-VersionTagToVersion64 -Tag $VersionTag -FallbackVersion64 $ModVersion64
if (-not (Test-Path -LiteralPath $DivinePath)) {
$resolvedCommand = Get-Command $DivinePath -ErrorAction SilentlyContinue
@@ -59,13 +89,64 @@ 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
$stagedMetaPath = Join-Path $stagingPath "Mods\\$ModFolder\\meta.lsx"
if (-not (Test-Path -LiteralPath $stagedMetaPath)) {
throw "Staged meta.lsx was not found: '$stagedMetaPath'."
}
if (-not (Test-Path -LiteralPath $tempPackagePath)) {
throw "Temporary package was not created."
$stagedMetaContent = Get-Content -LiteralPath $stagedMetaPath -Raw
$stagedMetaContent = $stagedMetaContent -replace '(<attribute id="Version64" type="int64" value=")\d+("/>)', "`${1}$resolvedVersion64`${2}"
Set-Content -LiteralPath $stagedMetaPath -Value $stagedMetaContent -Encoding utf8
Write-Host "[build.ps1] Staged source tree:"
Get-ChildItem -Recurse $stagingPath | Select-Object FullName, Length | Format-Table -AutoSize
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 +156,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")
@@ -88,7 +167,7 @@ $infoJson = [ordered]@{
Author = $ModAuthor
Name = $ModName
Folder = $ModFolder
Version = $ModVersion64
Version = [string]$resolvedVersion64
Description = $ModDescription
UUID = $ModUuid
Created = $createdAt

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
mkdir -p build
Divine -a create-package -g bg3 -s Mods -d "build/DnD 5.5e AIO Russian.pak"