# release.ps1 — Server Up release-script # # Eén commando: stage alles → commit → tag → push (commit + tag) naar Forgejo. # Forgejo Actions pakt de tag en bouwt automatisch het image met de juiste # SU_VERSION (zie .forgejo/workflows/build.yml of server-up-deploy/README.md). # # Gebruik: # .\release.ps1 -Version 0.3.02 -Message "Boilerplates YAML rendering fix" # # Optioneel: # -DryRun Toon alles, voer niets uit # -NoPush Wel taggen, niet pushen # -AllowDirty Sla de "wel echt iets gewijzigd?" check over # -ChangelogTop Plak een ## v$Version blok bovenaan CHANGELOG.md [CmdletBinding()] param( [Parameter(Mandatory = $true)][string]$Version, [Parameter(Mandatory = $true)][string]$Message, [string]$Remote = "origin", [switch]$DryRun, [switch]$NoPush, [switch]$AllowDirty, [switch]$ChangelogTop ) $ErrorActionPreference = "Stop" # ── Sanity checks ───────────────────────────────────────────────────────────── # Versie formaat (semver met optionele suffix) if ($Version -notmatch '^\d+\.\d+(\.\d+)?([\-_.][\w]+)?$') { throw "Versie moet 'x.y' of 'x.y.z' formaat zijn, kreeg: '$Version'" } # In een git repo? $gitRoot = & git rev-parse --show-toplevel 2>$null if ($LASTEXITCODE -ne 0) { throw "Niet in een git-repository" } Set-Location $gitRoot Write-Host "Repo: $gitRoot" -ForegroundColor DarkGray # Tag bestaat al? $existing = & git tag --list "v$Version" if ($existing) { throw "Tag v$Version bestaat al — kies een ander versienummer of verwijder de tag eerst" } # Iets om te committen? $status = & git status --porcelain if (-not $status -and -not $AllowDirty) { Write-Host "Geen wijzigingen om te committen." -ForegroundColor Yellow $reply = Read-Host "Alleen taggen op huidige HEAD? [y/N]" if ($reply -notmatch '^[yY]') { exit 0 } $tagOnly = $true } else { $tagOnly = $false } # ── Plan tonen ──────────────────────────────────────────────────────────────── Write-Host "" Write-Host "═══ Release plan ═══" -ForegroundColor Cyan Write-Host " Versie : v$Version" Write-Host " Bericht: $Message" Write-Host " Remote : $Remote" if ($DryRun) { Write-Host " Mode : DRY RUN — niets wordt uitgevoerd" -ForegroundColor Yellow } if ($tagOnly) { Write-Host " Mode : alleen tag (geen nieuwe commit)" -ForegroundColor Yellow } if ($NoPush) { Write-Host " Push : OVERGESLAGEN" -ForegroundColor Yellow } if (-not $tagOnly) { Write-Host "" Write-Host "Gewijzigde bestanden:" -ForegroundColor DarkGray & git status --short } # ── Optioneel: CHANGELOG bijwerken ──────────────────────────────────────────── if ($ChangelogTop -and -not $DryRun -and -not $tagOnly) { $clog = Join-Path $gitRoot "CHANGELOG.md" if (Test-Path $clog) { $date = Get-Date -Format "yyyy-MM-dd" $header = "# v$Version — $date`n`n$Message`n`n---`n`n" $original = Get-Content $clog -Raw Set-Content $clog ($header + $original) -NoNewline & git add CHANGELOG.md Write-Host "✓ CHANGELOG.md bijgewerkt" -ForegroundColor Green } } # ── Uitvoeren ───────────────────────────────────────────────────────────────── function Run([string]$Description, [scriptblock]$Action) { Write-Host "→ $Description" -ForegroundColor Cyan if (-not $DryRun) { & $Action } } if (-not $tagOnly) { Run "git add -A" { & git add -A } Run "git commit" { # Commit met header "release: vX.Y.Z" + jouw message als body & git commit -m "release: v$Version" -m $Message if ($LASTEXITCODE -ne 0) { throw "git commit faalde" } } } Run "git tag -a v$Version" { & git tag -a "v$Version" -m "v$Version — $Message" if ($LASTEXITCODE -ne 0) { throw "git tag faalde" } } if (-not $NoPush) { Run "git push $Remote HEAD" { & git push $Remote HEAD if ($LASTEXITCODE -ne 0) { throw "git push (commit) faalde" } } Run "git push $Remote v$Version" { & git push $Remote "v$Version" if ($LASTEXITCODE -ne 0) { throw "git push (tag) faalde" } } } # ── Klaar ───────────────────────────────────────────────────────────────────── Write-Host "" Write-Host "✓ Release v$Version klaar" -ForegroundColor Green if (-not $NoPush -and -not $DryRun) { Write-Host " Forgejo Actions bouwt nu het image (zie repo → Actions)" -ForegroundColor DarkGray Write-Host " Daarna op je server:" -ForegroundColor DarkGray Write-Host " SU_VERSION=$Version in .env" -ForegroundColor DarkGray Write-Host " docker compose pull && docker compose up -d" -ForegroundColor DarkGray }