-
Notifications
You must be signed in to change notification settings - Fork 4
/
package.ps1
39 lines (35 loc) · 1.23 KB
/
package.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
#!/bin/pwsh
$ErrorActionPreference = "Stop"
# Create zip archive containing replays
$useZip = $false
if (Get-Command "zip" -ErrorAction SilentlyContinue)
{
# Use zip if possible as it handles permissions better on unix
$useZip = $true
Write-Host "Using zip instead of Compress-Archive"
}
Write-Host -ForegroundColor Cyan "Re-creating artifacts directory..."
Remove-Item -Force -Recurse artifacts -ErrorAction SilentlyContinue
New-Item -Force -ItemType Directory artifacts | Out-Null
Write-Host -ForegroundColor Cyan "Copying replays..."
Push-Location replays
Copy-Item -Recurse ../replays ../artifacts/
Pop-Location
Write-Host -ForegroundColor Cyan "Creating final archive..."
if ($useZip)
{
Push-Location "artifacts/replays"
zip -r9 "../replays.zip" (Get-ChildItem).Name
if ($LASTEXITCODE -ne 0)
{
throw "zip failed with $LASTEXITCODE"
}
Pop-Location
}
else
{
Compress-Archive -Force "artifacts/replays/*" -DestinationPath "artifacts/replays.zip" -CompressionLevel Optimal
}
Remove-Item -Force -Recurse artifacts/replays
$fileHash = Get-FileHash "artifacts/replays.zip" -Algorithm SHA1 | Select-Object Hash
Write-Host -ForegroundColor Cyan "::set-output name=SHA1::" $fileHash.Hash