Подготовлена поддержка тестовых релизных тегов
This commit is contained in:
@@ -40,6 +40,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
git -c "http.extraHeader=Authorization: Basic $authBasic" fetch --depth 1 origin $repoRef
|
git -c "http.extraHeader=Authorization: Basic $authBasic" fetch --depth 1 origin $repoRef
|
||||||
|
git -c "http.extraHeader=Authorization: Basic $authBasic" fetch --force --tags origin
|
||||||
git checkout --force FETCH_HEAD
|
git checkout --force FETCH_HEAD
|
||||||
|
|
||||||
if (-not (Test-Path -LiteralPath "Mods\\DnD 5.5e AIO Russian\\Localization\\Russian\\russian.xml")) {
|
if (-not (Test-Path -LiteralPath "Mods\\DnD 5.5e AIO Russian\\Localization\\Russian\\russian.xml")) {
|
||||||
@@ -109,6 +110,7 @@ jobs:
|
|||||||
throw "Release archive was not found at '$zipPath'."
|
throw "Release archive was not found at '$zipPath'."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$isPrerelease = $tagName -match '^v\d+\.\d+\.\d+-'
|
||||||
$owner = $repoParts[0]
|
$owner = $repoParts[0]
|
||||||
$repo = $repoParts[1]
|
$repo = $repoParts[1]
|
||||||
$apiBase = "$serverUrl/api/v1/repos/$owner/$repo"
|
$apiBase = "$serverUrl/api/v1/repos/$owner/$repo"
|
||||||
@@ -137,10 +139,19 @@ jobs:
|
|||||||
name = $tagName
|
name = $tagName
|
||||||
target_commitish = "${{ gitea.sha }}"
|
target_commitish = "${{ gitea.sha }}"
|
||||||
draft = $false
|
draft = $false
|
||||||
prerelease = $false
|
prerelease = $isPrerelease
|
||||||
} | ConvertTo-Json
|
} | ConvertTo-Json
|
||||||
|
|
||||||
$release = Invoke-RestMethod -Method Post -Uri "$apiBase/releases" -Headers $headers -ContentType "application/json" -Body $releaseBody
|
$release = Invoke-RestMethod -Method Post -Uri "$apiBase/releases" -Headers $headers -ContentType "application/json" -Body $releaseBody
|
||||||
|
} elseif ($release.prerelease -ne $isPrerelease) {
|
||||||
|
$releaseBody = @{
|
||||||
|
tag_name = $tagName
|
||||||
|
target_commitish = "${{ gitea.sha }}"
|
||||||
|
draft = $false
|
||||||
|
prerelease = $isPrerelease
|
||||||
|
} | ConvertTo-Json
|
||||||
|
|
||||||
|
$release = Invoke-RestMethod -Method Patch -Uri "$apiBase/releases/$($release.id)" -Headers $headers -ContentType "application/json" -Body $releaseBody
|
||||||
}
|
}
|
||||||
|
|
||||||
$existingAsset = $null
|
$existingAsset = $null
|
||||||
|
|||||||
39
.github/workflows/build.yml
vendored
39
.github/workflows/build.yml
vendored
@@ -43,10 +43,15 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
$versionTag = ""
|
$versionTag = ""
|
||||||
|
$isPrerelease = "false"
|
||||||
if ($env:GITHUB_REF -like "refs/tags/v*") {
|
if ($env:GITHUB_REF -like "refs/tags/v*") {
|
||||||
$versionTag = $env:GITHUB_REF_NAME
|
$versionTag = $env:GITHUB_REF_NAME
|
||||||
|
if ($versionTag -match '^v\d+\.\d+\.\d+-') {
|
||||||
|
$isPrerelease = "true"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"version_tag=$versionTag" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
"version_tag=$versionTag" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
||||||
|
"is_prerelease=$isPrerelease" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
||||||
|
|
||||||
- name: Notify Telegram about build start
|
- name: Notify Telegram about build start
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
@@ -113,6 +118,7 @@ jobs:
|
|||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
$tagName = "${{ github.ref_name }}"
|
$tagName = "${{ github.ref_name }}"
|
||||||
$zipPath = Join-Path $env:GITHUB_WORKSPACE "build\\DnD 5.5e AIO Russian $tagName.zip"
|
$zipPath = Join-Path $env:GITHUB_WORKSPACE "build\\DnD 5.5e AIO Russian $tagName.zip"
|
||||||
|
$isPrerelease = "${{ steps.vars.outputs.is_prerelease }}" -eq "true"
|
||||||
|
|
||||||
if (-not (Test-Path -LiteralPath $zipPath)) {
|
if (-not (Test-Path -LiteralPath $zipPath)) {
|
||||||
throw "Release archive was not found at '$zipPath'."
|
throw "Release archive was not found at '$zipPath'."
|
||||||
@@ -121,15 +127,40 @@ jobs:
|
|||||||
gh release view $tagName --repo "${{ github.repository }}" *> $null
|
gh release view $tagName --repo "${{ github.repository }}" *> $null
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
gh release create $tagName $zipPath `
|
$args = @(
|
||||||
--repo "${{ github.repository }}" `
|
"release", "create", $tagName, $zipPath,
|
||||||
--title $tagName `
|
"--repo", "${{ github.repository }}",
|
||||||
--notes ""
|
"--title", $tagName,
|
||||||
|
"--notes", ""
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($isPrerelease) {
|
||||||
|
$args += "--prerelease"
|
||||||
|
}
|
||||||
|
|
||||||
|
gh @args
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gh release upload $tagName $zipPath `
|
gh release upload $tagName $zipPath `
|
||||||
--repo "${{ github.repository }}" `
|
--repo "${{ github.repository }}" `
|
||||||
--clobber
|
--clobber
|
||||||
|
|
||||||
|
$releaseId = gh release view $tagName `
|
||||||
|
--repo "${{ github.repository }}" `
|
||||||
|
--json id `
|
||||||
|
--jq ".id"
|
||||||
|
|
||||||
|
$releaseBodyPath = Join-Path $env:RUNNER_TEMP "release-body.json"
|
||||||
|
@{
|
||||||
|
name = $tagName
|
||||||
|
prerelease = $isPrerelease
|
||||||
|
} | ConvertTo-Json -Compress | Set-Content -LiteralPath $releaseBodyPath -Encoding utf8
|
||||||
|
|
||||||
|
gh api `
|
||||||
|
--method PATCH `
|
||||||
|
-H "Accept: application/vnd.github+json" `
|
||||||
|
"/repos/${{ github.repository }}/releases/$releaseId" `
|
||||||
|
--input $releaseBodyPath
|
||||||
}
|
}
|
||||||
|
|
||||||
- name: Notify Telegram about build success
|
- name: Notify Telegram about build success
|
||||||
|
|||||||
@@ -122,6 +122,12 @@ Source of truth:
|
|||||||
Rules:
|
Rules:
|
||||||
- do not change `PublishVersion`
|
- do not change `PublishVersion`
|
||||||
- tag MUST match version
|
- tag MUST match version
|
||||||
|
- tag formats:
|
||||||
|
- stable: `vX.Y.Z` -> `Version64 = X.Y.Z.0`
|
||||||
|
- suffixed: `vX.Y.Z-suffix` -> `Version64 = X.Y.Z.N`
|
||||||
|
- for suffixed tags, suffix affects tag/release channel only and is NOT encoded in `Version64`
|
||||||
|
- for suffixed tags on the same base version `X.Y.Z`, increment `build` (`N`) by counting prior released tags `vX.Y.Z-*`; current release uses the next value starting from `1`
|
||||||
|
- stable tag without suffix always uses `build = 0`, even if suffixed releases for the same base version already existed
|
||||||
|
|
||||||
Before tag:
|
Before tag:
|
||||||
1. if version already changed → use it
|
1. if version already changed → use it
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<attribute id="PublishHandle" type="uint64" value="5965149"/>
|
<attribute id="PublishHandle" type="uint64" value="5965149"/>
|
||||||
<attribute id="StartupLevelName" type="FixedString" value=""/>
|
<attribute id="StartupLevelName" type="FixedString" value=""/>
|
||||||
<attribute id="UUID" type="FixedString" value="6401e84d-daf2-416d-adeb-99c03a2487a6"/>
|
<attribute id="UUID" type="FixedString" value="6401e84d-daf2-416d-adeb-99c03a2487a6"/>
|
||||||
<attribute id="Version64" type="int64" value="281490009096192"/>
|
<attribute id="Version64" type="int64" value="281492156579841"/>
|
||||||
<children>
|
<children>
|
||||||
<node id="PublishVersion">
|
<node id="PublishVersion">
|
||||||
<attribute id="Version64" type="int64" value="281477124194304"/>
|
<attribute id="Version64" type="int64" value="281477124194304"/>
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ $ErrorActionPreference = "Stop"
|
|||||||
function Convert-VersionTagToVersion64 {
|
function Convert-VersionTagToVersion64 {
|
||||||
param(
|
param(
|
||||||
[string]$Tag,
|
[string]$Tag,
|
||||||
[string]$FallbackVersion64
|
[string]$FallbackVersion64,
|
||||||
|
[string]$RepoPath
|
||||||
)
|
)
|
||||||
|
|
||||||
if (-not $Tag) {
|
if (-not $Tag) {
|
||||||
@@ -32,16 +33,31 @@ function Convert-VersionTagToVersion64 {
|
|||||||
$normalized = $normalized.Substring(1)
|
$normalized = $normalized.Substring(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($normalized -notmatch '^\d+(\.\d+){0,3}$') {
|
if ($normalized -notmatch '^(?<base>\d+\.\d+\.\d+)(?:-(?<suffix>[0-9A-Za-z][0-9A-Za-z.-]*))?$') {
|
||||||
return [int64]$FallbackVersion64
|
throw "Version tag '$Tag' is invalid. Expected format: vX.Y.Z or vX.Y.Z-suffix"
|
||||||
}
|
}
|
||||||
|
|
||||||
$parts = $normalized.Split(".")
|
$baseVersion = $Matches.base
|
||||||
|
$suffix = $Matches.suffix
|
||||||
|
$parts = $baseVersion.Split(".")
|
||||||
$numbers = @(0, 0, 0, 0)
|
$numbers = @(0, 0, 0, 0)
|
||||||
for ($i = 0; $i -lt $parts.Length; $i++) {
|
for ($i = 0; $i -lt $parts.Length; $i++) {
|
||||||
$numbers[$i] = [int]$parts[$i]
|
$numbers[$i] = [int]$parts[$i]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($suffix) {
|
||||||
|
$resolvedRepoPath = [System.IO.Path]::GetFullPath($RepoPath)
|
||||||
|
$matchingTags = @()
|
||||||
|
|
||||||
|
try {
|
||||||
|
$matchingTags = @(git -C $resolvedRepoPath tag --list "v$baseVersion-*" 2>$null | Where-Object { $_ -and $_ -ne $Tag })
|
||||||
|
} catch {
|
||||||
|
$matchingTags = @()
|
||||||
|
}
|
||||||
|
|
||||||
|
$numbers[3] = $matchingTags.Count + 1
|
||||||
|
}
|
||||||
|
|
||||||
return ([int64]$numbers[0] -shl 55) -bor ([int64]$numbers[1] -shl 47) -bor ([int64]$numbers[2] -shl 31) -bor [int64]$numbers[3]
|
return ([int64]$numbers[0] -shl 55) -bor ([int64]$numbers[1] -shl 47) -bor ([int64]$numbers[2] -shl 31) -bor [int64]$numbers[3]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +75,7 @@ if ($VersionTag) {
|
|||||||
}
|
}
|
||||||
$zipPath = Join-Path $buildPath "$archiveName.zip"
|
$zipPath = Join-Path $buildPath "$archiveName.zip"
|
||||||
$infoJsonPath = Join-Path $buildPath "info.json"
|
$infoJsonPath = Join-Path $buildPath "info.json"
|
||||||
$resolvedVersion64 = Convert-VersionTagToVersion64 -Tag $VersionTag -FallbackVersion64 $ModVersion64
|
$resolvedVersion64 = Convert-VersionTagToVersion64 -Tag $VersionTag -FallbackVersion64 $ModVersion64 -RepoPath $workspacePath
|
||||||
|
|
||||||
if (-not (Test-Path -LiteralPath $DivinePath)) {
|
if (-not (Test-Path -LiteralPath $DivinePath)) {
|
||||||
$resolvedCommand = Get-Command $DivinePath -ErrorAction SilentlyContinue
|
$resolvedCommand = Get-Command $DivinePath -ErrorAction SilentlyContinue
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$VersionTag,
|
[string]$VersionTag,
|
||||||
[string]$MetaPath = "Mods/DnD 5.5e AIO Russian/meta.lsx"
|
[string]$MetaPath = "Mods/DnD 5.5e AIO Russian/meta.lsx",
|
||||||
|
[string]$RepositoryPath = "."
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
function Convert-VersionTagToVersion64 {
|
function Get-ReleaseVersionParts {
|
||||||
param(
|
param(
|
||||||
[string]$Tag
|
[string]$Tag,
|
||||||
|
[string]$RepoPath
|
||||||
)
|
)
|
||||||
|
|
||||||
$normalized = $Tag
|
$normalized = $Tag
|
||||||
@@ -16,17 +18,36 @@ function Convert-VersionTagToVersion64 {
|
|||||||
$normalized = $normalized.Substring(1)
|
$normalized = $normalized.Substring(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($normalized -notmatch '^\d+(\.\d+){0,3}$') {
|
if ($normalized -notmatch '^(?<base>\d+\.\d+\.\d+)(?:-(?<suffix>[0-9A-Za-z][0-9A-Za-z.-]*))?$') {
|
||||||
throw "Version tag '$Tag' is invalid. Expected format: vX.Y.Z or X.Y.Z"
|
throw "Version tag '$Tag' is invalid. Expected format: vX.Y.Z or vX.Y.Z-suffix"
|
||||||
}
|
}
|
||||||
|
|
||||||
$parts = $normalized.Split(".")
|
$baseVersion = $Matches.base
|
||||||
|
$suffix = $Matches.suffix
|
||||||
|
$parts = $baseVersion.Split(".")
|
||||||
$numbers = @(0, 0, 0, 0)
|
$numbers = @(0, 0, 0, 0)
|
||||||
for ($i = 0; $i -lt $parts.Length; $i++) {
|
for ($i = 0; $i -lt $parts.Length; $i++) {
|
||||||
$numbers[$i] = [int]$parts[$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]
|
if ($suffix) {
|
||||||
|
$resolvedRepoPath = [System.IO.Path]::GetFullPath($RepoPath)
|
||||||
|
$matchingTags = @()
|
||||||
|
|
||||||
|
try {
|
||||||
|
$matchingTags = @(git -C $resolvedRepoPath tag --list "v$baseVersion-*" 2>$null | Where-Object { $_ -and $_ -ne $Tag })
|
||||||
|
} catch {
|
||||||
|
$matchingTags = @()
|
||||||
|
}
|
||||||
|
|
||||||
|
$numbers[3] = $matchingTags.Count + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return [pscustomobject]@{
|
||||||
|
BaseVersion = $baseVersion
|
||||||
|
Suffix = $suffix
|
||||||
|
Version64 = ([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)
|
$resolvedMetaPath = [System.IO.Path]::GetFullPath($MetaPath)
|
||||||
@@ -34,7 +55,8 @@ if (-not (Test-Path -LiteralPath $resolvedMetaPath)) {
|
|||||||
throw "meta.lsx was not found: '$resolvedMetaPath'."
|
throw "meta.lsx was not found: '$resolvedMetaPath'."
|
||||||
}
|
}
|
||||||
|
|
||||||
$resolvedVersion64 = Convert-VersionTagToVersion64 -Tag $VersionTag
|
$releaseVersion = Get-ReleaseVersionParts -Tag $VersionTag -RepoPath $RepositoryPath
|
||||||
|
$resolvedVersion64 = $releaseVersion.Version64
|
||||||
$utf8Encoding = [System.Text.UTF8Encoding]::new($false)
|
$utf8Encoding = [System.Text.UTF8Encoding]::new($false)
|
||||||
$metaContent = [System.IO.File]::ReadAllText($resolvedMetaPath, $utf8Encoding)
|
$metaContent = [System.IO.File]::ReadAllText($resolvedMetaPath, $utf8Encoding)
|
||||||
[xml]$metaXml = $metaContent
|
[xml]$metaXml = $metaContent
|
||||||
@@ -60,4 +82,4 @@ $updatedMeta = [regex]::Replace(
|
|||||||
|
|
||||||
[System.IO.File]::WriteAllText($resolvedMetaPath, $updatedMeta, $utf8Encoding)
|
[System.IO.File]::WriteAllText($resolvedMetaPath, $updatedMeta, $utf8Encoding)
|
||||||
|
|
||||||
Write-Host "[set-version.ps1] Updated '$resolvedMetaPath' to Version64=$resolvedVersion64 (from tag '$VersionTag')."
|
Write-Host "[set-version.ps1] Updated '$resolvedMetaPath' to Version64=$resolvedVersion64 (from tag '$VersionTag', base '$($releaseVersion.BaseVersion)')."
|
||||||
|
|||||||
Reference in New Issue
Block a user