From a72b7bc1e1ec72cfe83fa3fe36812624004ffc78 Mon Sep 17 00:00:00 2001 From: Shahovalov MIkhail Date: Thu, 9 Apr 2026 07:00:35 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D1=81=D0=B8=D0=B8=20meta.lsx=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=20=D0=B2=D1=8B=D0=BF=D1=83=D1=81=D0=BA=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 5 +++++ scripts/set-version.ps1 | 49 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 scripts/set-version.ps1 diff --git a/AGENTS.md b/AGENTS.md index d7258a4..7d5a4e4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -91,6 +91,11 @@ Current behavior: Do not manually hardcode release versions in the committed `meta.lsx` for each release if CI can derive them from tags. +Release preparation rule: + +- before creating a release tag, run `scripts/set-version.ps1 -VersionTag ` to update repository `Mods/DnD 5.5e AIO Russian/meta.lsx` +- only after that commit the change and create/push the release tag + ## info.json Expectations `info.json` is generated during build and should remain aligned with BG3/BG3ModManager expectations. diff --git a/scripts/set-version.ps1 b/scripts/set-version.ps1 new file mode 100644 index 0000000..765c29c --- /dev/null +++ b/scripts/set-version.ps1 @@ -0,0 +1,49 @@ +param( + [Parameter(Mandatory = $true)] + [string]$VersionTag, + [string]$MetaPath = "Mods/DnD 5.5e AIO Russian/meta.lsx" +) + +$ErrorActionPreference = "Stop" + +function Convert-VersionTagToVersion64 { + param( + [string]$Tag + ) + + $normalized = $Tag + if ($normalized.StartsWith("v")) { + $normalized = $normalized.Substring(1) + } + + if ($normalized -notmatch '^\d+(\.\d+){0,3}$') { + throw "Version tag '$Tag' is invalid. Expected format: vX.Y.Z or X.Y.Z" + } + + $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] +} + +$resolvedMetaPath = [System.IO.Path]::GetFullPath($MetaPath) +if (-not (Test-Path -LiteralPath $resolvedMetaPath)) { + throw "meta.lsx was not found: '$resolvedMetaPath'." +} + +$resolvedVersion64 = Convert-VersionTagToVersion64 -Tag $VersionTag +$metaContent = Get-Content -LiteralPath $resolvedMetaPath -Raw + +$versionPattern = '()' +if ($metaContent -notmatch $versionPattern) { + throw "Version64 attributes were not found in '$resolvedMetaPath'." +} +$updatedMeta = $metaContent -replace $versionPattern, "`${1}$resolvedVersion64`${2}" + +$utf8Bom = New-Object System.Text.UTF8Encoding($true) +[System.IO.File]::WriteAllText($resolvedMetaPath, $updatedMeta, $utf8Bom) + +Write-Host "[set-version.ps1] Updated '$resolvedMetaPath' to Version64=$resolvedVersion64 (from tag '$VersionTag')."