fix: release_to_gitea.ps1にAPKバージョン一致チェックを追加
pubspec.yamlのversionとAPKの埋め込みversionNameが異なる場合は エラーで中断する。「バージョン上げ前ビルド→リリース」ミスを防ぐ。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
402c6b6448
commit
ba5660c1cb
|
|
@ -36,10 +36,34 @@ if ($apkFiles.Count -eq 0) { Write-Error "No APK files in: $ApkDir"; exit 1 }
|
||||||
# Read version from pubspec.yaml
|
# Read version from pubspec.yaml
|
||||||
$publine = Get-Content (Join-Path $PSScriptRoot "pubspec.yaml") | Where-Object { $_ -match "^version:" } | Select-Object -First 1
|
$publine = Get-Content (Join-Path $PSScriptRoot "pubspec.yaml") | Where-Object { $_ -match "^version:" } | Select-Object -First 1
|
||||||
$version = if ($publine -match "version:\s*(\S+)") { $Matches[1].Split("+")[0] } else { "1.0.0" }
|
$version = if ($publine -match "version:\s*(\S+)") { $Matches[1].Split("+")[0] } else { "1.0.0" }
|
||||||
$dateStr = (Split-Path $ApkDir -Leaf).Substring(0, 10)
|
$buildNum = if ($publine -match "version:\s*[^+]+\+(\S+)") { $Matches[1] } else { "0" }
|
||||||
|
$dateStr = Get-Date -Format "yyyy-MM-dd"
|
||||||
$tagName = "v$version"
|
$tagName = "v$version"
|
||||||
$relName = "Ponshu Room $version ($dateStr)"
|
$relName = "Ponshu Room $version ($dateStr)"
|
||||||
|
|
||||||
|
# APKの埋め込みバージョンと pubspec.yaml が一致するか確認
|
||||||
|
Write-Host " Checking APK version matches pubspec ($version+$buildNum)..." -ForegroundColor Gray
|
||||||
|
$firstApk = $apkFiles | Select-Object -First 1
|
||||||
|
$apkInfo = & flutter.bat --version 2>$null
|
||||||
|
# aapt2 でバージョン確認(利用可能な場合)
|
||||||
|
$aapt2 = Get-ChildItem "$env:LOCALAPPDATA\Android\Sdk\build-tools" -Recurse -Filter "aapt2.exe" -ErrorAction SilentlyContinue | Sort-Object FullName -Descending | Select-Object -First 1 -ExpandProperty FullName
|
||||||
|
if ($aapt2) {
|
||||||
|
$apkDump = & $aapt2 dump badging $firstApk.FullName 2>$null | Select-String "versionName|versionCode"
|
||||||
|
$apkVersion = if ($apkDump -match "versionName='([^']+)'") { $Matches[1] } else { $null }
|
||||||
|
$apkBuild = if ($apkDump -match "versionCode='([^']+)'") { $Matches[1] } else { $null }
|
||||||
|
if ($apkVersion -and $apkVersion -ne $version) {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host " [ERROR] APK version mismatch!" -ForegroundColor Red
|
||||||
|
Write-Host " APK contains : $apkVersion (build $apkBuild)" -ForegroundColor Red
|
||||||
|
Write-Host " pubspec.yaml : $version+$buildNum" -ForegroundColor Red
|
||||||
|
Write-Host " -> Rebuild APKs after version bump, then retry." -ForegroundColor Yellow
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
Write-Host " OK: APK version = $apkVersion (build $apkBuild)" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host " (aapt2 not found, skipping version check)" -ForegroundColor DarkGray
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "================================================" -ForegroundColor Cyan
|
Write-Host "================================================" -ForegroundColor Cyan
|
||||||
Write-Host " Ponshu Room - Gitea Auto Release" -ForegroundColor Cyan
|
Write-Host " Ponshu Room - Gitea Auto Release" -ForegroundColor Cyan
|
||||||
Write-Host "================================================" -ForegroundColor Cyan
|
Write-Host "================================================" -ForegroundColor Cyan
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue