146 lines
6 KiB
PowerShell
146 lines
6 KiB
PowerShell
# Paca 원클릭 통합 릴리스 & 사이트 배포 스크립트
|
|
#
|
|
# 동작:
|
|
# 1) Windows 설치자(x64, arm64) 빌드 (+ 선택: Android APK, 원격 Linux/macOS 머신 빌드)
|
|
# 2) NAS Git(Forgejo)의 공개 릴리스 저장소(Paca/releases)에 릴리스 생성 및 자산 업로드
|
|
# 3) (선택: -DeploySite) releases.json 갱신 및 Cloudflare Pages 배포
|
|
#
|
|
# 사용 예시:
|
|
# ./build/release.ps1 -Version 1.0.0 -Publish -DeploySite
|
|
# ./build/release.ps1 -Version 1.0.0-preview -Prerelease
|
|
# ./build/release.ps1 -Version 1.0.0 -SkipBuild -Publish -DeploySite
|
|
|
|
param(
|
|
[Parameter(Mandatory=$true)][string]$Version,
|
|
[string]$Config = "Release",
|
|
[switch]$Publish,
|
|
[switch]$Prerelease,
|
|
[switch]$SkipBuild,
|
|
[switch]$IncludeAndroid,
|
|
[switch]$IncludeRemote,
|
|
[switch]$DeploySite,
|
|
[string]$Notes = "",
|
|
[string]$Repo = "Video-Downloader/releases"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
$outDir = Join-Path $root "out"
|
|
|
|
Write-Host "======================================================" -ForegroundColor Cyan
|
|
Write-Host " Paca 릴리스 파이프라인 (v$Version)" -ForegroundColor Cyan
|
|
Write-Host "======================================================" -ForegroundColor Cyan
|
|
|
|
# ── 1. .env 환경변수 로드 ────────────────────────────────────
|
|
$envFile = Join-Path $root ".env"
|
|
if (Test-Path $envFile) {
|
|
foreach ($line in Get-Content $envFile) {
|
|
if ($line -match '^\s*([A-Za-z0-9_]+)\s*=\s*(.+)$') {
|
|
$k = $Matches[1]; $v = $Matches[2].Trim()
|
|
if (-not (Get-Item "env:$k" -ErrorAction SilentlyContinue)) {
|
|
Set-Item "env:$k" $v
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$hasAuth = ($env:RELEASE_TOKEN) -or ($env:FORGEJO_TOKEN) -or ($env:FORGEJO_USER -and $env:FORGEJO_PASSWORD)
|
|
if (-not $hasAuth) {
|
|
throw ".env 에 FORGEJO_TOKEN 또는 FORGEJO_USER/PASSWORD 가 없습니다. Forgejo 인증을 설정하세요."
|
|
}
|
|
|
|
# ── 2. 아티팩트 빌드 ─────────────────────────────────────────
|
|
if (-not $SkipBuild) {
|
|
Write-Host "`n[1/4] Windows 설치자 빌드 (x64, arm64)" -ForegroundColor Yellow
|
|
& (Join-Path $PSScriptRoot "publish.ps1") -Config $Config -Version $Version
|
|
if ($LASTEXITCODE -ne 0) { throw "Windows 설치자 빌드 실패" }
|
|
|
|
if ($IncludeAndroid) {
|
|
Write-Host "`n[2/4] Android APK 빌드" -ForegroundColor Yellow
|
|
$mobileCsproj = Join-Path $root "src\Paca.Mobile\Paca.Mobile.csproj"
|
|
$androidOut = Join-Path $outDir "android"
|
|
dotnet publish $mobileCsproj -f net10.0-android -c $Config -p:AndroidPackageFormat=apk -p:CiPackArm64Only=true -o $androidOut
|
|
if ($LASTEXITCODE -eq 0) {
|
|
$apk = Get-ChildItem (Join-Path $androidOut "*Signed.apk") | Select-Object -First 1
|
|
if (-not $apk) {
|
|
$apk = Get-ChildItem (Join-Path $androidOut "*.apk") | Select-Object -First 1
|
|
}
|
|
if ($apk) {
|
|
$targetApk = Join-Path $outDir "Paca-$Version-arm64.apk"
|
|
Copy-Item $apk.FullName $targetApk -Force
|
|
Write-Host "Android APK 생성 완료: $targetApk" -ForegroundColor Green
|
|
}
|
|
} else {
|
|
Write-Warning "Android 빌드 실패 (워크로드 미설치 시 건너뜁니다)"
|
|
}
|
|
}
|
|
|
|
if ($IncludeRemote) {
|
|
Write-Host "`n[3/4] Linux / macOS 원격 빌드머신 빌드" -ForegroundColor Yellow
|
|
$remoteScript = Join-Path $PSScriptRoot "remote\build-remote.sh"
|
|
if (Get-Command bash -ErrorAction SilentlyContinue) {
|
|
bash $remoteScript all
|
|
} else {
|
|
Write-Warning "bash 명령어를 찾을 수 없어 원격 빌드를 건너뜁니다."
|
|
}
|
|
}
|
|
} else {
|
|
Write-Host "`n[빌드 건너뜀 (-SkipBuild)]" -ForegroundColor DarkGray
|
|
}
|
|
|
|
# ── 3. 수집된 자산 목록 확인 ──────────────────────────────────
|
|
$assetsToUpload = @()
|
|
$candPatterns = @(
|
|
"Paca-Setup-*.exe",
|
|
"Paca-Setup-*.msi",
|
|
"Paca-*-arm64.apk",
|
|
"Paca-*.tar.gz"
|
|
)
|
|
|
|
foreach ($pat in $candPatterns) {
|
|
Get-ChildItem -Path $outDir -Filter $pat -ErrorAction SilentlyContinue | ForEach-Object {
|
|
$assetsToUpload += $_.FullName
|
|
}
|
|
}
|
|
|
|
if ($assetsToUpload.Count -eq 0) {
|
|
throw "업로드할 릴리스 산출물이 out/ 디렉토리에 없습니다."
|
|
}
|
|
|
|
Write-Host "`n업로드 대상 자산 ($($assetsToUpload.Count)개):" -ForegroundColor Cyan
|
|
foreach ($a in $assetsToUpload) {
|
|
$f = Get-Item $a
|
|
Write-Host (" - {0,-35} ({1:N1} MB)" -f $f.Name, ($f.Length / 1MB))
|
|
}
|
|
|
|
# ── 4. NAS Git (Forgejo) 릴리스 등록 및 업로드 ────────────────
|
|
Write-Host "`n[4/4] NAS Git (Forgejo) 릴리스 업로드 ($Repo)" -ForegroundColor Yellow
|
|
$tag = "v$Version"
|
|
$uploadScript = Join-Path $PSScriptRoot "ci\upload-release-asset.ps1"
|
|
|
|
$uploadArgs = @{
|
|
Tag = $tag
|
|
Files = $assetsToUpload
|
|
Repo = $Repo
|
|
}
|
|
if ($Publish) { $uploadArgs["Publish"] = $true }
|
|
if ($Notes) { $uploadArgs["Notes"] = $Notes }
|
|
|
|
$global:LASTEXITCODE = 0
|
|
& $uploadScript @uploadArgs
|
|
|
|
# ── 5. 사이트 배포 (옵션) ────────────────────────────────────
|
|
if ($DeploySite) {
|
|
Write-Host "`n[추가] Cloudflare Pages 사이트 배포" -ForegroundColor Yellow
|
|
$global:LASTEXITCODE = 0
|
|
& (Join-Path $PSScriptRoot "deploy-site.ps1")
|
|
}
|
|
|
|
Write-Host "`n======================================================" -ForegroundColor Green
|
|
Write-Host " 릴리스 완료: $tag" -ForegroundColor Green
|
|
if ($Publish) {
|
|
Write-Host " 상태: 정식 공개(Published)" -ForegroundColor Green
|
|
} else {
|
|
Write-Host " 상태: 초안(Draft) - 웹 UI(https://git.chanpaca.net/$Repo/releases)에서 확인 후 공개 가능" -ForegroundColor Yellow
|
|
}
|
|
Write-Host "======================================================" -ForegroundColor Green
|