This commit is contained in:
Ivan Fontosh
2026-05-18 08:35:36 +08:00
parent 4e5d320c36
commit cfa067519d
6 changed files with 167 additions and 18 deletions
+88 -12
View File
@@ -1,17 +1,26 @@
# Prepare TTRPG release: bump version, git push, build Win/Linux, copy to release folder.
# Prepare TTRPG release: build Win/Linux, copy to release folder.
# Run: prepare-release.cmd
#
# Recommended (Mac first, same version on all platforms):
# 1) Bump version in package.json manually (npm version patch --no-git-tag-version)
# 2) pack:mac on Mac, copy latest-mac.yml + *.zip to release folder
# 3) prepare-release.cmd -AfterMac (or release-all.cmd)
#
# Options:
# -Version 1.0.17 explicit version (skip auto bump)
# -Patch bump patch (default)
# -Minor bump minor
# -AfterMac do not bump; require Mac files in release folder (default in release-all)
# -Bump bump patch before build (Mac can be added later)
# -Version 1.0.17 set explicit version (with -Bump workflow)
# -Minor bump minor (with -Bump)
# -SkipGit skip commit/push
# -SkipLinux skip Linux build (WSL)
# -NoBump do not change package.json version
# -NoBump do not change package.json (same as -AfterMac without Mac check)
param(
[string]$Version = '',
[switch]$Patch,
[switch]$Minor,
[switch]$Bump,
[switch]$AfterMac,
[switch]$SkipGit,
[switch]$SkipLinux,
[switch]$NoBump
@@ -149,6 +158,45 @@ function Push-Git([string]$ProjectRoot, [string]$Remote, [string]$McpConfigPath)
}
}
function Get-YmlField([string]$ymlPath, [string]$fieldName) {
$content = Get-Content -LiteralPath $ymlPath -Raw -Encoding UTF8
$m = [regex]::Match($content, "(?m)^${fieldName}:\s*(\S+)\s*$")
if ($m.Success) {
return $m.Groups[1].Value.Trim()
}
return $null
}
function Test-MacReleaseReady {
param(
[string]$ReleaseDir,
[string]$ExpectedVersion
)
$macYml = Join-Path $ReleaseDir 'latest-mac.yml'
if (-not (Test-Path -LiteralPath $macYml)) {
throw @"
AfterMac: missing latest-mac.yml in $ReleaseDir
1) Bump version in package.json (now $ExpectedVersion)
2) npm run pack:mac on Mac
3) Copy latest-mac.yml + TTRPGPlayer-*.zip into release folder
4) Run prepare-release.cmd -AfterMac again
"@
}
$macVersion = Get-YmlField $macYml 'version'
if ($macVersion -and $macVersion -ne $ExpectedVersion) {
throw "AfterMac: latest-mac.yml is v$macVersion but package.json is v$ExpectedVersion. Align versions before building Win/Linux."
}
$primary = Get-YmlField $macYml 'path'
if (-not $primary) {
throw 'AfterMac: latest-mac.yml has no path: entry'
}
$primaryPath = Join-Path $ReleaseDir $primary
if (-not (Test-Path -LiteralPath $primaryPath)) {
throw "AfterMac: missing Mac update file $primary (path in latest-mac.yml). Copy zip from Mac build."
}
Write-Ok "Mac feed v$ExpectedVersion, primary: $primary"
}
function Copy-ReleaseArtifacts {
param(
[string]$BuildReleaseDir,
@@ -228,12 +276,36 @@ Write-Host '=== TTRPG Prepare Release ===' -ForegroundColor Cyan
Write-Host "Project: $projectRoot"
Write-Host "Release folder: $releaseDir"
# Step 1 - version
Write-Step 1 'Bump version'
$currentVersion = Read-PackageVersion $packageJson
$newVersion = $currentVersion
if ($AfterMac) {
$NoBump = $true
}
if ($Bump -and $AfterMac) {
throw 'Use either -Bump or -AfterMac, not both'
}
if ($Bump) {
$Patch = $true
}
if ($NoBump) {
$currentVersion = Read-PackageVersion $packageJson
if ($AfterMac) {
Write-Step 0 'Mac artifacts check'
Test-MacReleaseReady $releaseDir $currentVersion
}
# Step 1 - version
if ($AfterMac) {
Write-Step 1 'Version (unchanged, Mac-first workflow)'
$newVersion = $currentVersion
Write-Ok "building Win/Linux at v$newVersion (same as Mac feed)"
} else {
Write-Step 1 'Bump version'
$newVersion = $currentVersion
}
if ($AfterMac) {
# version step done above
} elseif ($NoBump) {
Write-Ok "version unchanged: $currentVersion"
$newVersion = $currentVersion
} elseif ($Version) {
@@ -310,8 +382,12 @@ Write-Host '=== Prepare release done ===' -ForegroundColor Green
Write-Host "Version: $newVersion"
Write-Host ''
Write-Host 'Next steps:' -ForegroundColor Yellow
Write-Host ' 1) Copy Mac files (latest-mac.yml, TTRPGPlayer-*.zip, optional *.dmg) from Mac into release folder if needed'
Write-Host ' 2) Run publish.cmd to validate and upload to updates.mailib.ru'
if ($AfterMac) {
Write-Host ' Run publish.cmd (release-all continues to publish automatically)'
} else {
Write-Host ' 1) Copy Mac files (latest-mac.yml, TTRPGPlayer-*.zip) from Mac into release folder'
Write-Host ' 2) Run release-all.cmd (default -AfterMac) or publish.cmd'
}
Write-Host ''
exit 0