-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
69 lines (62 loc) · 2.79 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
Import-Module Microsoft.PowerShell.Utility
$cwd = (Get-Location).Path
$ahkpath = 'C:\Users\Jacques\scoop\apps\autohotkey\current'
$ahk2exe = $ahkpath + '\Compiler\Ahk2Exe.exe'
$ahk64base = $ahkpath + '\v2\AutoHotkey64.exe'
$command = $ahk2exe + ' /silent verbose ' + ' /base ' + $ahk64base + " /out $cwd\build\"
$testcommand = $ahk2exe + ' /base ' + $ahk64base + " /out $cwd\test\"
$version = $args[0]
$env = $args[1]
$appname = $args[2]
$zipname = $appname + '_v' + "$version"
$setversion = ';@Ahk2Exe-SetVersion ' + $version
$globalversion = "Global appVersion := `"" + $version + "`""
Write-Host 'App:' $appname
Write-Host 'Version:' $version
Write-Host 'Environment:' $env
if ($env -eq 'version') {
Get-ChildItem “$cwd\*.ahk” | ForEach-Object {
(Get-Content $_) | ForEach-Object { $_ -Replace (';@Ahk2Exe-SetVersion ' + '[0-9]+.[0-9]+.[0-9]+') , $setversion } | Set-Content $_
(Get-Content $_) | ForEach-Object { $_ -Replace ("Global appVersion := `"" + '[0-9]+.[0-9]+.[0-9]+' + "`"") , $globalversion } | Set-Content $_
}
}
if ($env -eq 'prod') {
if (!(Test-Path -Path "$cwd\build")) {
mkdir $cwd\build
}
Get-ChildItem “$cwd\*.ahk” | ForEach-Object {
(Get-Content $_) | ForEach-Object { $_ -Replace (';@Ahk2Exe-SetVersion ' + '[0-9]+.[0-9]+.[0-9]+') , $setversion } | Set-Content $_
(Get-Content $_) | ForEach-Object { $_ -Replace ("Global appVersion := `"" + '[0-9]+.[0-9]+.[0-9]+' + "`"") , $globalversion } | Set-Content $_
}
foreach ($file in (Get-ChildItem -Path $cwd\*.ahk)) {
Write-Host $file.BaseName
Invoke-Expression($command + " /in $file")
while ( !(Test-Path -Path "$cwd\build\$($file.BaseName).exe" )) {
Start-Sleep 1
}
}
if ((Test-Path -Path "$cwd\build\checksums_v$version.txt")) {
Remove-Item -Path $cwd\build\checksums_v$version.txt
}
if ((Test-Path -Path "$cwd\build\$zipname.zip")) {
Remove-Item -Force -Path $cwd\build\$zipname.zip
}
Compress-Archive -Path .\build\*.exe -DestinationPath .\build\$zipname.zip
$value = (Get-FileHash -Path .\build\$zipname.zip -Algorithm SHA256).Hash + " $zipname.zip"
Tee-Object -Append -InputObject $value -FilePath $cwd\build\checksums_v$version.txt
foreach ($file in (Get-ChildItem -Path $cwd\build\*.exe)) {
Invoke-Expression("Remove-Item -Force -Path $file")
}
}
if ($env -eq 'dev') {
if (!(Test-Path -Path "$cwd\test")) {
mkdir $cwd\test
}
foreach ($file in (Get-ChildItem -Path $cwd\*.ahk)) {
Write-Host $file.BaseName
Invoke-Expression($testcommand + " /in $file")
while ( !(Test-Path -Path "$cwd\test\$($file.BaseName).exe" )) {
Start-Sleep 1
}
}
}