|
1 | 1 | $cwd = (Get-Location).Path;
|
2 | 2 |
|
3 |
| -Remove-Item -Path "$cwd\build\*" -Recurse -Force; |
| 3 | +# Get the latest version from tag |
| 4 | +git pull; |
| 5 | +$latestTag = git describe --tags --abbrev=0; |
| 6 | +$versionNumber = (Select-String -Pattern "\d+\.\d+\.\d+" -InputObject $latestTag).Matches[0].Value |
4 | 7 |
|
5 |
| -Ahk2Exe.exe /in polygon.ahk /out "$cwd\build\polygon-x64.exe" /icon logo.ico /base "$HOME\.scoop\apps\autohotkey\current\v2\AutoHotkey64.exe"; |
6 |
| -Ahk2Exe.exe /in polygon.ahk /out "$cwd\build\polygon-x86.exe" /icon logo.ico /base "$HOME\.scoop\apps\autohotkey\current\v2\AutoHotkey32.exe"; |
| 8 | +Write-Host "Building Polygon version $versionNumber" -ForegroundColor Green; |
7 | 9 |
|
8 |
| -candle.exe .\polygon.wxs -out "$cwd\build\polygon-x86.wixobj" -dVersion="0.0.0" -arch x86; |
9 |
| -candle.exe .\polygon.wxs -out "$cwd\build\polygon-x64.wixobj" -dVersion="0.0.0" -arch x64; |
| 10 | +# Clean build folder |
| 11 | +Remove-Item -Path "$cwd\build" -Recurse -Force -ErrorAction SilentlyContinue; |
| 12 | +New-Item -Path "$cwd\build" -ItemType Directory; |
10 | 13 |
|
11 |
| -light.exe "$cwd\build\polygon-x86.wixobj" -ext WixUIExtension -out "$cwd\build\polygon-x86.msi"; |
12 |
| -light.exe "$cwd\build\polygon-x64.wixobj" -ext WixUIExtension -out "$cwd\build\polygon-x64.msi"; |
| 14 | +# Download AutoHotkey |
| 15 | +$ahkFileNamePattern = "AutoHotkey_.*\.zip" |
| 16 | +$ahkLatestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/AutoHotkey/AutoHotkey/releases/latest"; |
| 17 | +$ahkDownloadURL = ($ahkLatestRelease.assets | Where-Object { $_.name -match "$ahkFileNamePattern" }) | Select-Object -ExpandProperty browser_download_url |
| 18 | +Invoke-WebRequest -Uri $ahkDownloadURL -OutFile "$cwd\build\autohotkey.zip"; |
| 19 | +Expand-Archive -Path "$cwd\build\autohotkey.zip" -DestinationPath "$cwd\build\ahk"; |
| 20 | + |
| 21 | +Write-Host "Downloaded the latest release from AutoHotkey into `"$cwd\build\ahk\`"" -ForegroundColor Green; |
| 22 | + |
| 23 | +# Download Ahk2Exe |
| 24 | +$ahk2ExeFileNamePattern = "Ahk2Exe.*\.zip" |
| 25 | +$ahk2ExeLatestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/AutoHotkey/Ahk2Exe/releases/latest"; |
| 26 | +$ahk2ExeDownloadURL = ($ahk2ExeLatestRelease.assets | Where-Object { $_.name -match "$ahk2ExeFileNamePattern" }) | Select-Object -ExpandProperty browser_download_url |
| 27 | +Invoke-WebRequest -Uri $ahk2ExeDownloadURL -OutFile "$cwd\build\Ahk2exe.zip"; |
| 28 | +Expand-Archive -Path "$cwd\build\Ahk2exe.zip" -DestinationPath "$cwd\build\ahk"; |
| 29 | + |
| 30 | +Write-Host "Downloaded the latest release from Ahk2Exe into `"$cwd\build\ahk\`"" -ForegroundColor Green; |
| 31 | + |
| 32 | +# Download Wix3 |
| 33 | +$wixFileNamePattern = "wix311-binaries.zip" |
| 34 | +$wixLatestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/wixtoolset/wix3/releases/latest"; |
| 35 | +$wixDownloadURL = ($wixLatestRelease.assets | Where-Object { $_.name -match "$wixFileNamePattern" }) | Select-Object -ExpandProperty browser_download_url |
| 36 | +Invoke-WebRequest -Uri $wixDownloadURL -OutFile "$cwd\build\$wixFileNamePattern"; |
| 37 | +Expand-Archive -Path "$cwd\build\$wixFileNamePattern" -DestinationPath "$cwd\build\wix\"; |
| 38 | + |
| 39 | +Write-Host "Downloaded the latest release from Wix3 into `"$cwd\build\wix\`"" -ForegroundColor Green; |
| 40 | + |
| 41 | +& "$cwd\build\ahk\Ahk2Exe.exe" /in polygon.ahk /out "$cwd\build\polygon-x64.exe" /icon logo.ico /base "$cwd\build\ahk\AutoHotkey64.exe"; |
| 42 | +& "$cwd\build\ahk\Ahk2Exe.exe" /in polygon.ahk /out "$cwd\build\polygon-x86.exe" /icon logo.ico /base "$cwd\build\ahk\AutoHotkey32.exe"; |
| 43 | + |
| 44 | +Write-Host "Polygon binaries built successfully into `"$cwd\build\`"" -ForegroundColor Green; |
| 45 | + |
| 46 | +& "$cwd\build\wix\candle.exe" .\polygon.wxs -out "$cwd\build\polygon-x86.wixobj" -dVersion="$versionNumber" -arch x86; |
| 47 | +& "$cwd\build\wix\candle.exe" .\polygon.wxs -out "$cwd\build\polygon-x64.wixobj" -dVersion="$versionNumber" -arch x64; |
| 48 | + |
| 49 | +& "$cwd\build\wix\light.exe" "$cwd\build\polygon-x86.wixobj" -ext WixUIExtension -out "$cwd\build\polygon-x86.msi"; |
| 50 | +& "$cwd\build\wix\light.exe" "$cwd\build\polygon-x64.wixobj" -ext WixUIExtension -out "$cwd\build\polygon-x64.msi"; |
| 51 | + |
| 52 | +Write-Host "Polygon installers built successfully into `"$cwd\build\`"" -ForegroundColor Green; |
0 commit comments