-
Notifications
You must be signed in to change notification settings - Fork 2
/
package_release.ps1
50 lines (43 loc) · 1.74 KB
/
package_release.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function CreateReleaseZip
{
param (
$FilesToZip,
$OutputName
)
# remove old zip file
if (Test-Path $OutputName)
{
Remove-Item $OutputName -ErrorAction Stop
}
Push-Location ".."
$FullFilenames = $FilesToZip | ForEach-Object -Process {Write-Output -InputObject $_.FullName}
# #create zip file
Add-Type -AssemblyName System.IO.Compression
Add-Type -AssemblyName System.IO.Compression.FileSystem
$zip = [System.IO.Compression.ZipFile]::Open(($OutputName), [System.IO.Compression.ZipArchiveMode]::Create)
# #write entries with relative paths as names
foreach ($fname in $FullFilenames)
{
$rname = $(Resolve-Path -Path $fname -Relative) -replace '\.\\',''
Write-Output $rname
$zentry = $zip.CreateEntry($rname)
$zentryWriter = New-Object -TypeName System.IO.BinaryWriter $zentry.Open()
$zentryWriter.Write([System.IO.File]::ReadAllBytes($fname))
$zentryWriter.Flush()
$zentryWriter.Close()
}
# #release zip file
$zip.Dispose()
Pop-Location
}
# Set-Location ".."
# collecting list of files that we want to archive excluding those that we don't want to preserve
Push-Location ".."
$Files = @(Get-ChildItem "plugins" -Recurse -File -ErrorAction SilentlyContinue | Where-Object { ($_.Extension -in '.dll')})
$Files += @(Get-ChildItem "data" -Recurse -File -ErrorAction SilentlyContinue | Where-Object { ($_.Extension -in '.png')})
Pop-Location
CreateReleaseZip $Files ("..\" +$args[0] + "_RELEASE.zip")
Push-Location ".."
$Files += @(Get-ChildItem "plugins" -Recurse -File -ErrorAction SilentlyContinue | Where-Object { ($_.Extension -in '.pdb')})
Pop-Location
CreateReleaseZip $Files ("..\" + $args[0] + "_PDB.zip")