|
| 1 | +param( |
| 2 | + [string]$OutputDir = ".release" |
| 3 | +) |
| 4 | + |
| 5 | +$ErrorActionPreference = "Stop" |
| 6 | + |
| 7 | +$manifest = Get-Content -Raw "manifest.json" | ConvertFrom-Json |
| 8 | +$version = [string]$manifest.version |
| 9 | +$packageName = "Web2Comics-v$version" |
| 10 | +$stagingRoot = Join-Path $OutputDir $packageName |
| 11 | +$zipPath = Join-Path $OutputDir "$packageName-extension.zip" |
| 12 | + |
| 13 | +if (Test-Path $OutputDir) { |
| 14 | + Remove-Item $OutputDir -Recurse -Force |
| 15 | +} |
| 16 | + |
| 17 | +New-Item -ItemType Directory -Path $stagingRoot | Out-Null |
| 18 | + |
| 19 | +$runtimeDirs = @( |
| 20 | + "background", |
| 21 | + "content", |
| 22 | + "icons", |
| 23 | + "options", |
| 24 | + "popup", |
| 25 | + "providers", |
| 26 | + "shared", |
| 27 | + "sidepanel" |
| 28 | +) |
| 29 | + |
| 30 | +foreach ($dir in $runtimeDirs) { |
| 31 | + Copy-Item $dir -Destination $stagingRoot -Recurse |
| 32 | +} |
| 33 | + |
| 34 | +Copy-Item "manifest.json" -Destination $stagingRoot |
| 35 | +Copy-Item "INSTALL.md" -Destination $stagingRoot |
| 36 | + |
| 37 | +$docsDir = Join-Path $stagingRoot "docs" |
| 38 | +New-Item -ItemType Directory -Path $docsDir | Out-Null |
| 39 | +Copy-Item "docs/user-manual.html" -Destination (Join-Path $docsDir "user-manual.html") |
| 40 | + |
| 41 | +# Strip developer docs and optional local artifacts from the runtime folders. |
| 42 | +Get-ChildItem -Path $stagingRoot -Recurse -File -Filter "README.md" | Remove-Item -Force |
| 43 | +Get-ChildItem -Path $stagingRoot -Recurse -File -Filter "*.local.json" | Remove-Item -Force |
| 44 | +$typesPath = Join-Path $stagingRoot "shared/types.js" |
| 45 | +if (Test-Path $typesPath) { |
| 46 | + Remove-Item $typesPath -Force |
| 47 | +} |
| 48 | + |
| 49 | +Compress-Archive -Path $stagingRoot -DestinationPath $zipPath -CompressionLevel Optimal -Force |
| 50 | + |
| 51 | +Write-Output "Created: $zipPath" |
0 commit comments