Repository navigation
Expand file tree
/
Copy pathBuild.ps1
More file actions
104 lines (82 loc) · 2.49 KB
/
Copy pathBuild.ps1
File metadata and controls
104 lines (82 loc) · 2.49 KB
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
104
param(
[string]$scriptPath = "$PSScriptRoot\..\QuickSwitch.ahk",
[string]$outDir = "$PSScriptRoot\..\Releases",
[string]$scriptVersion = "",
[string]$sevenZip = "C:\Program Files\7-Zip\7z.exe",
[string]$autoHotkeyDir = "C:\Program Files\AutoHotkey",
[string]$compiler = "$autoHotkeyDir\Compiler\Ahk2Exe.exe"
)
$ErrorActionPreference = 'Stop'
$scriptBase = Split-Path $scriptPath -leafBase
$scriptDir = Split-Path $scriptPath -parent
$outExe = Join-Path $outDir "$scriptBase.exe"
$compileParams = @(
'/in', $scriptPath,
'/out', $outExe,
'/silent', 'verbose'
)
$zipParams = @(
'a', # archive
# '-bb1', # verbose output
'-bso0', # disable non-error messages
'-y', # "yes" to all prompts (silent)
'-aoa', # overwrite without prompts (silent)
'-sae', # exact archive name
'-mx=0' # no compression (to prevent antivirus and scan issues)
)
if (!(Test-Path -Literal $outDir)) {
New-Item -ItemType Directory -Path $outDir | Out-Null
}
Set-Location $outDir
# Archive for each platform
function Out {
[cmdletbinding()]
param (
[Parameter(Position=0, ValueFromPipeline)]
[string]$msg
)
if (-not ([string]::IsNullOrEmpty($msg))) {
$msg.Trim("`r","`n") | Out-String
}
}
$archives = [System.Collections.Generic.List[string]]@()
ForEach($bitness in @('64', '32')) {
$interpreterPath = "{0}\AutoHotkeyU{1}.exe" -f `
$autoHotkeyDir, $bitness
&$compiler @compileParams /base $interpreterPath | Out-String
if (!$scriptVersion) {
$ver = (Get-Item $outExe).VersionInfo.FileVersion
$scriptVersion = $ver.Trim('.0')
}
$archivePath = "{0}-{1}-x{2}.zip" -f `
$scriptBase, $scriptVersion, $bitness
&$sevenZip `
@zipParams `
$archivePath `
"$outExe" `
"$scriptDir\README.md" `
"$scriptDir\Icons" `
"$scriptDir\Favorites" |
Out
$archives.Add($archivePath)
}
# Archive source code
$archivePath = "{0}-{1}.zip" -f `
$scriptBase, $scriptVersion
&$sevenZip `
@zipParams `
$archivePath `
"$scriptPath" `
"$scriptDir\README.md" `
"$scriptDir\Icons" `
"$scriptDir\Favorites" `
"$scriptDir\Lib" |
Out
$archives.Add($archivePath)
# Output hashes
ForEach($path in $archives) {
Write-Host $path (Get-FileHash $path -Algorithm SHA256).hash
}
$artifact = Split-Path $archivePath -leafBase
"artifact=$artifact" >> $env:GITHUB_ENV
Remove-Item $outExe