diff --git a/release_to_gitea.ps1 b/release_to_gitea.ps1 index 731d88d..57c7aaf 100644 --- a/release_to_gitea.ps1 +++ b/release_to_gitea.ps1 @@ -36,10 +36,34 @@ if ($apkFiles.Count -eq 0) { Write-Error "No APK files in: $ApkDir"; exit 1 } # Read version from pubspec.yaml $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" } -$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" $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 " Ponshu Room - Gitea Auto Release" -ForegroundColor Cyan Write-Host "================================================" -ForegroundColor Cyan