param( [string]$Version = "0.1.0" ) $ErrorActionPreference = "Stop" Add-Type -AssemblyName System.IO.Compression Add-Type -AssemblyName System.IO.Compression.FileSystem $root = Split-Path -Parent $PSScriptRoot $source = Join-Path $root "src" $dist = Join-Path $root "dist" $zipPath = Join-Path $dist "Brogether-Brogether-$Version.zip" if (-not (Test-Path $source)) { throw "Missing source folder: $source" } New-Item -ItemType Directory -Force -Path $dist | Out-Null if (Test-Path $zipPath) { Remove-Item -LiteralPath $zipPath -Force } $archive = [System.IO.Compression.ZipFile]::Open($zipPath, [System.IO.Compression.ZipArchiveMode]::Create) try { $sourceRoot = (Resolve-Path $source).Path.TrimEnd('\', '/') Get-ChildItem -Path $sourceRoot -Recurse -File | ForEach-Object { $relativePath = $_.FullName.Substring($sourceRoot.Length + 1).Replace('\', '/') [System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile( $archive, $_.FullName, $relativePath, [System.IO.Compression.CompressionLevel]::Optimal ) | Out-Null } } finally { $archive.Dispose() } Write-Host "Created $zipPath"