49 lines
1.5 KiB
PowerShell
49 lines
1.5 KiB
PowerShell
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"
|
|
$releases = Join-Path $root "releases"
|
|
$zipPath = Join-Path $dist "Brogether-Brogether-$Version.zip"
|
|
$releaseZipPath = Join-Path $releases "Brogether-Brogether-$Version.zip"
|
|
|
|
if (-not (Test-Path $source)) {
|
|
throw "Missing source folder: $source"
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $dist | Out-Null
|
|
New-Item -ItemType Directory -Force -Path $releases | Out-Null
|
|
if (Test-Path $zipPath) {
|
|
Remove-Item -LiteralPath $zipPath -Force
|
|
}
|
|
if (Test-Path $releaseZipPath) {
|
|
Remove-Item -LiteralPath $releaseZipPath -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()
|
|
}
|
|
|
|
Copy-Item -LiteralPath $zipPath -Destination $releaseZipPath -Force
|
|
Write-Host "Created $zipPath"
|
|
Write-Host "Updated release artifact $releaseZipPath"
|