1
0
Fork 0

feat: 변환 안정성과 작업 흐름 개선

This commit is contained in:
Yun Chan 2026-11-04 15:53:45 +09:00
parent 4c942cf00b
commit 24221361b2
160 changed files with 64218 additions and 796 deletions

View file

@ -61,6 +61,32 @@ Write-Host " 버전: $Version (Tag: $Tag, Manifest: $FourPartVersion)" -Foregro
Write-Host " 대상: $ForgejoHost/$ForgejoOwner/$ForgejoRepo" -ForegroundColor Cyan
Write-Host "==========================================================" -ForegroundColor Cyan
# Native command failures do not obey ErrorActionPreference by themselves.
function Invoke-GitChecked {
param([Parameter(ValueFromRemainingArguments = $true)][string[]]$GitArguments)
$result = & git @GitArguments
if ($LASTEXITCODE -ne 0) { throw "git 작업 실패: $($GitArguments -join ' ') (exit $LASTEXITCODE)" }
return $result
}
# Release only committed source; never silently omit dirty application code.
Push-Location $RootDir
try {
$dirty = git status --porcelain
if ($LASTEXITCODE -ne 0) { throw "Git 상태 확인 실패" }
if ($dirty) { throw "미커밋 변경사항이 있습니다. 릴리즈할 코드를 먼저 커밋하세요." }
$branch = Invoke-GitChecked symbolic-ref --quiet --short HEAD
if (-not $branch) { throw "분리된 HEAD에서는 릴리즈할 수 없습니다." }
$localTag = Invoke-GitChecked tag -l $Tag
$remoteTag = git ls-remote --tags forgejo "refs/tags/$Tag" "refs/tags/$Tag^{}"
if ($LASTEXITCODE -ne 0) { throw "원격 태그 확인 실패" }
if ($localTag -or $remoteTag) { throw "이미 존재하는 태그: $Tag. 새 버전을 사용하세요." }
if ($DryRun) {
Write-Host "DryRun: 변경 없이 사전 검사만 완료. 테스트·버전 변경·빌드·게시를 실행하지 않았습니다."
return
}
} finally { Pop-Location }
# ── Gate 1: 테스트 스위트 100% 통과 검증 ────────────────────────────────
if (-not $SkipTests) {
Write-Host "`n[Gate 1] TDD 테스트 스위트 전체 실행 중..." -ForegroundColor Yellow
@ -143,6 +169,8 @@ if (-not $DryRun) {
}
}
if (-not (Test-Path (Join-Path $distDir "Everything2Everything-x64.msix"))) { throw "MSIX 파일이 생성되지 않았습니다." }
# 서명 무결성 검증 (0x800B010A 방지 게이트)
$msixFile = Join-Path $distDir "Everything2Everything-x64.msix"
if (Test-Path $msixFile) {
@ -167,10 +195,12 @@ if (-not $DryRun) {
if ($LASTEXITCODE -eq 0 -and (Test-Path $innoExe)) {
Write-Host " - Inno Setup 빌드 성공: $innoExe" -ForegroundColor Green
} else {
Write-Warning "Inno Setup 빌드 실패 (코드 $LASTEXITCODE)"
throw "Inno Setup 빌드 실패 (코드 $LASTEXITCODE)"
}
}
if (-not (Test-Path $innoExe)) { throw "Inno Setup 설치 파일이 생성되지 않았습니다." }
# 5. 1-클릭 설치 번들 ZIP 생성 (MSIX + .cer + Install.cmd + Install.ps1)
$setupZip = Join-Path $distDir "Everything2Everything-$Version-Setup.zip"
$cerFile = Join-Path $distDir "Everything2Everything-DevCert.cer"
@ -192,112 +222,58 @@ if (-not $DryRun) {
Write-Host "✅ 아티팩트 패키징 완료" -ForegroundColor Green
# ── Gate 4: Git 커밋, 태그 및 원격 푸시 ───────────────────────────────
Write-Host "`n[Gate 4] Git 태깅 및 원격 푸시 ($ForgejoHost)..." -ForegroundColor Yellow
if (-not $DryRun) {
# 변경사항 커밋
git add $manifestPath $appCsprojPath
git diff --cached --quiet
if ($LASTEXITCODE -ne 0) {
git commit -m "chore(release): $Tag - $ReleaseNotes"
Push-Location $RootDir
try {
# Only version files may have changed during the build.
$allowed = @('packaging/Package.appxmanifest', 'src/Everything2Everything.App/Everything2Everything.App.csproj')
$changed = @(Invoke-GitChecked diff --name-only HEAD)
if (@($changed | Where-Object { $_ -notin $allowed }).Count -gt 0) {
throw "빌드 중 소스가 변경되었습니다. 다시 검증하고 커밋하세요."
}
$untracked = @(Invoke-GitChecked ls-files --others --exclude-standard)
if ($untracked.Count -gt 0) { throw "빌드 중 미추적 파일이 생성되었습니다. 검토 후 다시 실행하세요." }
Invoke-GitChecked add -- $manifestPath $appCsprojPath | Out-Null
& git diff --cached --quiet
$diffExit = $LASTEXITCODE
if ($diffExit -eq 1) {
Invoke-GitChecked -c user.name="Yun Chan" commit -m "chore(release): $Tag" | Out-Null
} elseif ($diffExit -ne 0) { throw "버전 변경 확인 실패" }
$releaseCommit = (Invoke-GitChecked rev-parse HEAD).Trim()
Invoke-GitChecked tag -a $Tag -m "Release $Tag" | Out-Null
Invoke-GitChecked push forgejo HEAD | Out-Null
Invoke-GitChecked push forgejo "refs/tags/$Tag" | Out-Null
} finally { Pop-Location }
# 태그 생성 (기존 태그가 있다면 삭제 후 재생성 또는 확인)
$existingTag = git tag -l $Tag
if ($existingTag) {
Write-Host " - 기존 태그 $Tag 삭제 후 재생성..." -ForegroundColor Gray
git tag -d $Tag
# ── Gate 5: Forgejo release and assets; every failure is fatal ─────────
$authHeader = @{ Authorization = "token $env:FORGEJO_TOKEN" }
$releaseUrl = "$ForgejoHost/api/v1/repos/$ForgejoOwner/$ForgejoRepo/releases"
$releaseBody = @{
tag_name = $Tag
target_commitish = $releaseCommit
name = "Everything2Everything $Tag"
body = $ReleaseNotes
draft = $true
prerelease = $false
} | ConvertTo-Json
try {
# Keep incomplete uploads as a draft, publish only after asset verification.
$releaseResponse = Invoke-RestMethod -Uri $releaseUrl -Method Post -Headers $authHeader -ContentType 'application/json' -Body $releaseBody
if (-not $releaseResponse.id) { throw "릴리즈 응답에 ID가 없습니다." }
$assets = @($portableZip, $msixFile, $setupZip, $innoExe)
if (Test-Path -LiteralPath $cerFile) { $assets += $cerFile }
foreach ($asset in $assets) {
if (-not (Test-Path -LiteralPath $asset -PathType Leaf)) { throw "필수 배포 파일 누락: $asset" }
$file = Get-Item -LiteralPath $asset
if ($file.Length -le 0) { throw "빈 배포 파일: $asset" }
$uploadUrl = "$releaseUrl/$($releaseResponse.id)/assets?name=$([Uri]::EscapeDataString($file.Name))"
$uploaded = Invoke-RestMethod -Uri $uploadUrl -Method Post -Headers $authHeader -Form @{ attachment = $file }
if ($uploaded.size -ne $file.Length -or -not $uploaded.browser_download_url -or $uploaded.name -ne $file.Name) {
throw "첨부 파일 검증 실패: $($file.Name)"
}
}
git tag -a $Tag -m "Release ${Tag}: $ReleaseNotes"
Write-Host " - Git 태그 생성 완료: $Tag" -ForegroundColor Gray
# 원격 푸시
Write-Host " - Forgejo 원격 저장소로 푸시 중..." -ForegroundColor Gray
git push forgejo HEAD
git push forgejo $Tag --force
if ((git remote) -contains "origin") {
git push origin HEAD
git push origin $Tag --force
}
Write-Host "✅ Git 푸시 완료" -ForegroundColor Green
# ── Forgejo REST API 릴리즈 등록 ─────────────────────────────────
Write-Host "`n[Gate 5] Forgejo REST API 릴리즈 등록 중..." -ForegroundColor Yellow
$authHeader = @{
"Content-Type" = "application/json"
"Authorization" = "token $env:FORGEJO_TOKEN"
}
$releaseBody = @{
tag_name = $Tag
target_commitish = "main"
name = "Everything2Everything $Tag"
body = @"
## Everything2Everything $Tag
$ReleaseNotes
### 다운로드
- **표준 설치 프로그램 (권장)**: `Everything2Everything-$Version-Setup-x64.exe` (인증서 경고 없는 1초 설치)
- **Portable ZIP**: `Everything2Everything-$Version-win-x64-portable.zip` (무설치 경량 실행 파일)
- **MSIX 패키지**: `Everything2Everything-x64.msix` 및 1-클릭 설치 번들 `Everything2Everything-$Version-Setup.zip`
"@
draft = $false
prerelease = $false
} | ConvertTo-Json
try {
$releaseUrl = "$ForgejoHost/api/v1/repos/$ForgejoOwner/$ForgejoRepo/releases"
$existingReleases = Invoke-RestMethod -Uri $releaseUrl -Method Get -Headers $authHeader
$releaseResponse = $existingReleases | Where-Object { $_.tag_name -eq $Tag } | Select-Object -First 1
if (-not $releaseResponse) {
$releaseResponse = Invoke-RestMethod -Uri $releaseUrl -Method Post -Headers $authHeader -Body $releaseBody
Write-Host "✅ Forgejo 정식 릴리즈 생성 완료: $($releaseResponse.html_url)" -ForegroundColor Green
} else {
Write-Host "ℹ️ 기존 릴리즈 확인됨 (ID: $($releaseResponse.id)): $($releaseResponse.html_url)" -ForegroundColor Cyan
}
# 첨부 파일 업로드
$uploadUrl = "$ForgejoHost/api/v1/repos/$ForgejoOwner/$ForgejoRepo/releases/$($releaseResponse.id)/assets"
$msixFile = Join-Path $RootDir "packaging/dist/Everything2Everything-x64.msix"
$innoExe = Join-Path $distDir "Everything2Everything-$Version-Setup-x64.exe"
if (Test-Path $innoExe) {
Write-Host " - Inno Setup 표준 설치 파일(Setup-x64.exe) 업로드 중..." -ForegroundColor Gray
curl.exe -s -H "Authorization: token $env:FORGEJO_TOKEN" -X POST "$uploadUrl`?name=Everything2Everything-$Version-Setup-x64.exe" -F "attachment=@$innoExe" | Out-Null
Write-Host " -> Inno Setup 설치 파일 업로드 완료!" -ForegroundColor Gray
}
if (Test-Path $portableZip) {
Write-Host " - Portable ZIP 업로드 중..." -ForegroundColor Gray
curl.exe -s -H "Authorization: token $env:FORGEJO_TOKEN" -X POST "$uploadUrl`?name=Everything2Everything-$Version-win-x64-portable.zip" -F "attachment=@$portableZip" | Out-Null
Write-Host " -> Portable ZIP 업로드 완료!" -ForegroundColor Gray
}
if (Test-Path $msixFile) {
Write-Host " - MSIX 패키지 업로드 중..." -ForegroundColor Gray
curl.exe -s -H "Authorization: token $env:FORGEJO_TOKEN" -X POST "$uploadUrl`?name=Everything2Everything-x64.msix" -F "attachment=@$msixFile" | Out-Null
Write-Host " -> MSIX 업로드 완료!" -ForegroundColor Gray
}
if (Test-Path $setupZip) {
Write-Host " - 1-클릭 설치 번들 ZIP 업로드 중..." -ForegroundColor Gray
curl.exe -s -H "Authorization: token $env:FORGEJO_TOKEN" -X POST "$uploadUrl`?name=Everything2Everything-$Version-Setup.zip" -F "attachment=@$setupZip" | Out-Null
Write-Host " -> 1-클릭 설치 번들 ZIP 업로드 완료!" -ForegroundColor Gray
}
if (Test-Path $cerFile) {
Write-Host " - 공개 개발자 인증서(.cer) 업로드 중..." -ForegroundColor Gray
curl.exe -s -H "Authorization: token $env:FORGEJO_TOKEN" -X POST "$uploadUrl`?name=Everything2Everything-DevCert.cer" -F "attachment=@$cerFile" | Out-Null
Write-Host " -> 공개 개발자 인증서 업로드 완료!" -ForegroundColor Gray
}
} catch {
Write-Warning "Forgejo 릴리즈 API 호출 중 경고: $_"
}
} else {
Write-Host " (DryRun: Git 푸시 및 릴리즈 등록 건너뜀)" -ForegroundColor DarkGray
$published = Invoke-RestMethod -Uri "$releaseUrl/$($releaseResponse.id)" -Method Patch -Headers $authHeader -ContentType 'application/json' -Body '{"draft":false}'
if ($published.draft -ne $false -or $published.tag_name -ne $Tag) { throw "릴리즈 공개 상태 확인 실패" }
Write-Host "Everything2Everything $Tag 배포 완료: $($published.html_url)" -ForegroundColor Green
} catch {
throw "Forgejo 릴리즈 배포 실패. 태그나 draft를 자동 삭제하지 않습니다. 원인을 확인하세요: $_"
}
Write-Host "`n🎉 Everything2Everything $Tag 릴리즈 배포가 성공적으로 완료되었습니다!" -ForegroundColor Green
Write-Host "저장소 주소: $ForgejoHost/$ForgejoOwner/$ForgejoRepo" -ForegroundColor Cyan