-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.ps1
38 lines (28 loc) · 1.24 KB
/
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
if ($args.Count -ne 2)
{
Write-Host "usage: $PSCommandPath <version> <executable path>"
exit 1
}
$Version = $args[0]
$Executable = $args[1]
$ReleaseDir = "release/sim-$Version"
$ReleaseZip = "release/sim-$Version.zip"
Remove-Item -LiteralPath "$ReleaseDir" -Force -Recurse -ErrorAction Ignore
Remove-Item -LiteralPath "$ReleaseZip" -Force -ErrorAction Ignore
New-Item -ItemType Directory -Path "$ReleaseDir" | Out-Null
Copy-Item "assets" -Destination "$ReleaseDir" -Recurse
Copy-Item "config.ini" -Destination "$ReleaseDir"
Copy-Item "bin/lua51.dll" -Destination "$ReleaseDir"
$Log = "$env:TEMP/rh.log"
$LogUTF8 = "$Log.utf8"
bin/ResourceHacker.exe -open $Executable -save "$ReleaseDir/sim.exe" -action addskip -res "assets/icon.ico" -mask "ICONGROUP,MAINICON," -log $Log | Out-Null
Get-Content $Log -Encoding Unicode | Set-Content $LogUTF8 -Encoding Utf8
if (Select-String -Path $LogUTF8 -Pattern "Failed!" -Quiet)
{
Get-Content $LogUTF8
Write-Host "Error while running ResourceHacker!" -ForegroundColor Red
exit 2
}
Compress-Archive -Path $ReleaseDir -DestinationPath $ReleaseZip
Remove-Item -LiteralPath "$ReleaseDir" -Force -Recurse -ErrorAction Ignore
Write-Host "Release successfully packed to $ReleaseZip" -ForegroundColor Green