-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.ps1
103 lines (85 loc) · 2.47 KB
/
build.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
param (
[Parameter(Mandatory = $false)]
[switch]$Dev
)
####################################################################
function Remove-Folders {
param (
[Parameter(Mandatory=$true)]
[string[]]$Paths
)
foreach ($Path in $Paths) {
if (Test-Path $Path) {
Write-Output "Removing $Path..."
Remove-Item -Path $Path -Recurse -Force
} else {
Write-Output "Skipping $Path as it does not exist."
}
}
}
####################################################################
Write-Output "Building LOLauncher..."
$EnvName = "prod_venv"
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
Write-Output "Cleaning Up..."
Remove-Folders -Paths @(".\dist", ".\build", ".\$EnvName")
Write-Output "Building..."
Write-Output "Creating Virtual Environment..."
.\venv\Scripts\python.exe -m pip install --upgrade pip
.\venv\Scripts\pip.exe install -r requirements-dev.txt
.\venv\Scripts\python.exe -m venv $EnvName
Write-Output "Activating Virtual Environment..."
$ActivateScript = Join-Path -Path ".\" -ChildPath "$EnvName\Scripts\Activate.ps1"
. $ActivateScript
Write-Output "Installing Dependencies..."
& .\$EnvName\Scripts\python.exe -m pip install --upgrade pip
& .\$EnvName\Scripts\pip.exe install -r requirements.txt
Write-Output "Building Executable..."
$InstallerArgsDebug = @(
"--noconsole",
"--add-data",
".\src\assets\*.png;.\assets",
"--add-data",
".\src\assets\*.ico;.\assets",
# "--add-data",
# ".\src\assets\*.pdf;.\assets",
"--collect-data",
"sv_ttk",
"--paths",
".\src",
"--clean",
"--icon",
".\src\assets\icon.ico",
"--name",
"LOLauncher",
".\src\main.py"
)
$InstallerArgs = $InstallerArgsDebug + @(
"--log-level",
"WARN",
"--onefile"
)
if ($Dev)
{
& .\$EnvName\Scripts\pyinstaller.exe $InstallerArgsDebug
}
else
{
& .\$EnvName\Scripts\pyinstaller.exe $InstallerArgs
}
if ($Dev)
{
Write-Output "Debug mode enabled, skipping compression..."
& .\dist\LOLauncher\LOLauncher.exe
}
else
{
Write-Output "Creating Version File..."
& .\venv\Scripts\create-version-file.exe metadata.yml --outfile file_version_info.txt
Write-Output "Setting Version..."
& .\$EnvName\Scripts\pyi-set_version.exe ./file_version_info.txt ./dist/LOLauncher.exe
Write-Output "Compressing Files..."
Compress-Archive -Path .\dist\LOLauncher.exe -DestinationPath .\dist\LOLauncher.zip
}
Write-Output "Done!"