Skip to content

Commit

Permalink
Github Actions: Avoid weird bug with Powershell on Github Actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lymia committed Dec 19, 2023
1 parent 2d7fb0a commit d952528
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
- run: rm -Recurse -Force -Verbose target/mppatch_ci_natives-linux

# Do the actual build
- run: powershell -file scripts/ci/build-installer_win32.ps1
- run: pwsh -file scripts/ci/build-installer_win32.ps1

# Upload artifacts
- uses: actions/upload-artifact@v3
Expand Down
26 changes: 20 additions & 6 deletions scripts/ci/build-installer_win32.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,24 @@ target/rcedit.exe "target/mppatch-installer-stub.exe" `
--set-icon "scripts/res/mppatch-installer.ico" `
--application-manifest "scripts/res/win32-manifest.xml"

if ((get-host).version.major -le 5) {
Get-Content "target/mppatch-installer-stub.exe","target\mppatch-installer-data.dat" -Encoding Byte -Read 1024 `
| Set-Content "target\$INSTALLER_NAME" -Encoding Byte
} else {
Get-Content "target/mppatch-installer-stub.exe","target\mppatch-installer-data.dat" -AsByteStream -Read 1024 `
| Set-Content "target\$INSTALLER_NAME" -AsByteStream
# From: https://stackoverflow.com/questions/1783554/fast-and-simple-binary-concatenate-files-in-powershell
#
# We use this to bypass a very strange Github Actions problem.
function Join-File(
[parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
[string[]] $Path,
[parameter(Position = 1, Mandatory = $true)]
[string] $Destination
) {
echo "Join-File: Open Destination1 $Destination"
$OutFile = [System.IO.File]::Create($Destination)
foreach ($File in $Path) {
echo " Join-File: Open Source $File"
$InFile = [System.IO.File]::OpenRead($File)
$InFile.CopyTo($OutFile)
$InFile.Dispose()
}
$OutFile.Dispose()
echo "Join-File: finished"
}
join-file "target/mppatch-installer-stub.exe","target\mppatch-installer-data.dat" "target\$INSTALLER_NAME"

0 comments on commit d952528

Please sign in to comment.