74 lines
3.0 KiB
PowerShell
74 lines
3.0 KiB
PowerShell
|
|
param([switch]$SkipRelease)
|
||
|
|
|
||
|
|
# ============================================================================
|
||
|
|
# Ponshu Room - Consumer APK Build Script (Maita + Eiji)
|
||
|
|
# build.gradle.kts は変更しない。applicationId は既に ponshu_room_lite 固定。
|
||
|
|
# ============================================================================
|
||
|
|
|
||
|
|
$ErrorActionPreference = "Stop"
|
||
|
|
|
||
|
|
# .env.local を読み込む
|
||
|
|
$envFile = Join-Path $PSScriptRoot ".env.local"
|
||
|
|
if (-not (Test-Path $envFile)) { Write-Error ".env.local not found"; exit 1 }
|
||
|
|
Get-Content $envFile | ForEach-Object {
|
||
|
|
$line = $_.Trim()
|
||
|
|
if ($line -and -not $line.StartsWith('#') -and $line.Contains('=')) {
|
||
|
|
$idx = $line.IndexOf('=')
|
||
|
|
$key = $line.Substring(0, $idx).Trim()
|
||
|
|
$val = $line.Substring($idx + 1).Trim()
|
||
|
|
[System.Environment]::SetEnvironmentVariable($key, $val)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$maitaKey = $env:GEMINI_API_KEY_MAITA
|
||
|
|
$eijiKey = $env:GEMINI_API_KEY_EIJI
|
||
|
|
if (-not $maitaKey) { Write-Error "GEMINI_API_KEY_MAITA not set in .env.local"; exit 1 }
|
||
|
|
if (-not $eijiKey) { Write-Error "GEMINI_API_KEY_EIJI not set in .env.local"; exit 1 }
|
||
|
|
|
||
|
|
# 出力ディレクトリ
|
||
|
|
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
||
|
|
$outputDir = Join-Path $PSScriptRoot "build\apk_releases\$timestamp"
|
||
|
|
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
|
||
|
|
|
||
|
|
Write-Host "============================================" -ForegroundColor Cyan
|
||
|
|
Write-Host " Ponshu Room - Consumer APK Build" -ForegroundColor Cyan
|
||
|
|
Write-Host "============================================" -ForegroundColor Cyan
|
||
|
|
Write-Host " Output: $outputDir" -ForegroundColor Gray
|
||
|
|
Write-Host ""
|
||
|
|
|
||
|
|
# --- 1. Maita ---
|
||
|
|
Write-Host "[1/2] Building Maita..." -ForegroundColor Yellow
|
||
|
|
flutter build apk --release `
|
||
|
|
--dart-define=GEMINI_API_KEY=$maitaKey `
|
||
|
|
--dart-define=IS_BUSINESS_APP=false
|
||
|
|
|
||
|
|
if ($LASTEXITCODE -ne 0) { Write-Error "Maita build failed"; exit 1 }
|
||
|
|
|
||
|
|
Copy-Item "build\app\outputs\flutter-apk\app-release.apk" `
|
||
|
|
"$outputDir\ponshu_room_consumer_maita.apk" -Force
|
||
|
|
$sz = [math]::Round((Get-Item "$outputDir\ponshu_room_consumer_maita.apk").Length / 1MB, 1)
|
||
|
|
Write-Host " OK: ponshu_room_consumer_maita.apk ($sz MB)" -ForegroundColor Green
|
||
|
|
|
||
|
|
# --- 2. Eiji ---
|
||
|
|
Write-Host "[2/2] Building Eiji..." -ForegroundColor Yellow
|
||
|
|
flutter build apk --release `
|
||
|
|
--dart-define=GEMINI_API_KEY=$eijiKey `
|
||
|
|
--dart-define=IS_BUSINESS_APP=false
|
||
|
|
|
||
|
|
if ($LASTEXITCODE -ne 0) { Write-Error "Eiji build failed"; exit 1 }
|
||
|
|
|
||
|
|
Copy-Item "build\app\outputs\flutter-apk\app-release.apk" `
|
||
|
|
"$outputDir\ponshu_room_consumer_eiji.apk" -Force
|
||
|
|
$sz = [math]::Round((Get-Item "$outputDir\ponshu_room_consumer_eiji.apk").Length / 1MB, 1)
|
||
|
|
Write-Host " OK: ponshu_room_consumer_eiji.apk ($sz MB)" -ForegroundColor Green
|
||
|
|
|
||
|
|
Write-Host ""
|
||
|
|
Write-Host " Build complete: $outputDir" -ForegroundColor Cyan
|
||
|
|
|
||
|
|
# --- 3. Release to Gitea + Vercel ---
|
||
|
|
if (-not $SkipRelease) {
|
||
|
|
Write-Host ""
|
||
|
|
Write-Host " Releasing to Gitea..." -ForegroundColor Cyan
|
||
|
|
& "$PSScriptRoot\release_to_gitea.ps1" -ApkDir $outputDir
|
||
|
|
}
|