This commit is contained in:
Ivan Fontosh
2026-05-18 08:26:43 +08:00
parent 411ac634f4
commit 4e5d320c36
8 changed files with 145 additions and 17 deletions
+39 -8
View File
@@ -64,6 +64,11 @@ function Convert-ToWslPath([string]$winPath) {
return $p
}
function Get-WslLinuxBuildCommand([string]$WslProjectPath) {
# WSL Debian often has node 18 on PATH; scripts/wsl-pack-linux.sh uses nvm + .nvmrc.
return "cd '$WslProjectPath' && bash scripts/wsl-pack-linux.sh"
}
function Read-PackageVersion([string]$packageJsonPath) {
$json = Get-Content -LiteralPath $packageJsonPath -Raw -Encoding UTF8 | ConvertFrom-Json
return [string]$json.version
@@ -100,21 +105,47 @@ function Invoke-Git {
}
}
function Write-GitLines($lines) {
foreach ($line in $lines) {
if ($line -is [System.Management.Automation.ErrorRecord]) {
Write-Host $line.ToString()
} else {
Write-Host ([string]$line)
}
}
}
function Invoke-GitPush {
param(
[string]$ProjectRoot,
[string[]]$PushArgs
)
$prevEap = $ErrorActionPreference
$ErrorActionPreference = 'Continue'
try {
$output = & git -C $ProjectRoot push @PushArgs 2>&1
Write-GitLines $output
return $LASTEXITCODE
} finally {
$ErrorActionPreference = $prevEap
}
}
function Push-Git([string]$ProjectRoot, [string]$Remote, [string]$McpConfigPath) {
$branch = (git -C $ProjectRoot rev-parse --abbrev-ref HEAD).Trim()
Write-Host " > git push $Remote $branch"
& git -C $ProjectRoot push $Remote $branch 2>&1 | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -eq 0) {
$exitCode = Invoke-GitPush $ProjectRoot @($Remote, $branch)
if ($exitCode -eq 0) {
return
}
$pushUrl = Get-GiteaPushUrl $McpConfigPath
if (-not $pushUrl) {
throw "git push failed and no Gitea token in mcp config"
throw "git push failed (exit $exitCode) and no Gitea token in mcp config ($McpConfigPath)"
}
Write-Host " > git push via Gitea token URL"
& git -C $ProjectRoot push $pushUrl "HEAD:${branch}" 2>&1 | ForEach-Object { Write-Host $_ }
if ($LASTEXITCODE -ne 0) {
throw "git push failed (exit $LASTEXITCODE)"
$exitCode = Invoke-GitPush $ProjectRoot @($pushUrl, "HEAD:${branch}")
if ($exitCode -ne 0) {
throw "git push failed (exit $exitCode)"
}
}
@@ -252,7 +283,7 @@ if ($SkipLinux) {
} else {
Write-Step 4 'Build Linux via WSL (npm ci + pack:linux)'
$wslProject = Convert-ToWslPath $projectRoot
$wslCmd = "cd '$wslProject' && npm ci && npm run pack:linux"
$wslCmd = Get-WslLinuxBuildCommand $wslProject
$wslArgs = @()
if ($wslDistro) {
$wslArgs += '-d', $wslDistro
@@ -279,7 +310,7 @@ 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, *.dmg) from Mac into release folder if needed'
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'
Write-Host ''