-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.ps1
59 lines (50 loc) · 1.71 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# you must allow script execution by running
# 'Set-ExecutionPolicy RemoteSigned' in an admin powershell
# this requires vcvars to be already set (see vcvarsall17.ps1)
# 7zip is also required (choco install 7zip and add it to path)
$dir = Split-Path -Parent $MyInvocation.MyCommand.Definition
Push-Location "$dir"
git pull origin master -q
function Write-Header {
param ([string]$Text)
Write-Host $Text -Foreground Yellow -Background Black
}
function Header {
param ([string]$Title)
Write-Header ""
Write-Header "##########################################################"
Write-Header "> $Title"
}
cmd /c "build.bat"; if (-not $?) { exit $LastExitCode }
cmd /c "libbuild.bat"; if (-not $?) { exit $LastExitCode }
Header "Packaging"
$folder = "oppai-" + $(.\oppai.exe -version) + "-windows-"
$clout = & cl 2>&1 | %{ "$_" }
"$clout" -match "(Microsoft.*for )([a-z0-9\-_]+)" | Out-Null
if (-not $?) {
exit $LastExitCode
}
$folder = $folder + $Matches[2]
mkdir $folder; if (-not $?) { exit $LastExitCode }
Copy-Item oppai.exe $folder; if (-not $?) { exit $LastExitCode }
Copy-Item oppai.dll $folder; if (-not $?) { exit $LastExitCode }
Copy-Item oppai.lib $folder; if (-not $?) { exit $LastExitCode }
git archive HEAD --prefix=src\ -o $folder\src.zip
if (-not $?) {
exit $LastExitCode
}
Set-Location $folder; if (-not $?) { exit $LastExitCode }
&7z x src.zip; if (-not $?) { exit $LastExitCode }
Set-Location ..; if (-not $?) { exit $LastExitCode }
if (Test-Path "$folder.zip") {
Remove-Item "$folder.zip"
}
&7z a "$folder.zip" $folder\oppai.exe $folder\oppai.dll $folder\oppai.lib `
$folder\src
if (-not $?) {
exit $LastExitCode
}
Header "Result:"
&7z l "$folder.zip"
Remove-Item $folder -Force -Recurse
Pop-Location