Ship a self-contained Windows GUI with game shortcuts and application icons
CI / check (push) Successful in 1m30s
CI / windows (push) Failing after 4m27s

This commit is contained in:
faumaray committed 2026-11-27 23:34:01 +03:00
1 parent 329a1ad4df
commit 3ea497d38a
16 files changed
+589 -58

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
param(
[string]$OutputDirectory = (Join-Path $PSScriptRoot '..\..\target\dist'),
[string[]]$DllDirectory = @()
)
$ErrorActionPreference = 'Stop'
$repo = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
$destination = [IO.Path]::GetFullPath($OutputDirectory)
$dllDirs = @($DllDirectory | ForEach-Object { (Resolve-Path -LiteralPath $_).Path })
if (-not [Environment]::Is64BitProcess) { throw 'Run this build in x64 PowerShell.' }
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
$vs = & $vswhere -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
if ($LASTEXITCODE -ne 0 -or -not $vs) { throw 'Install the Visual Studio C++ x64 build tools and Windows SDK.' }
Import-Module (Join-Path $vs 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
Enter-VsDevShell -VsInstallPath $vs -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
# A short, fresh target path keeps link.exe below MAX_PATH on service-account runners.
$work = New-Item -ItemType Directory -Path (Join-Path ([IO.Path]::GetTempPath()) ([IO.Path]::GetRandomFileName()))
Push-Location $repo
try {
$env:CARGO_TARGET_DIR = Join-Path $work.FullName 'b'
# With --target, Cargo applies this to target crates only. The encoded setting
# takes precedence over inherited RUSTFLAGS, including on self-hosted runners.
$env:CARGO_ENCODED_RUSTFLAGS = '-Ctarget-feature=+crt-static'
$env:VCPKGRS_DISABLE = '1'
cargo build --locked --release --target x86_64-pc-windows-msvc --features vendored-lua,curl/static-curl
if ($LASTEXITCODE -ne 0) { throw "Windows build failed ($LASTEXITCODE)." }
$binary = Join-Path $env:CARGO_TARGET_DIR 'x86_64-pc-windows-msvc\release\rusty-path-of-building.exe'
$venv = Join-Path $work.FullName 'py'
python -m venv $venv
if ($LASTEXITCODE -ne 0) { throw "Could not create the packaging environment ($LASTEXITCODE)." }
$packagingPython = Join-Path $venv 'Scripts\python.exe'
& $packagingPython -m pip install --disable-pip-version-check --no-input --require-hashes -r packaging/windows/requirements.txt
if ($LASTEXITCODE -ne 0) { throw "Windows packaging dependency installation failed ($LASTEXITCODE)." }
# A third-party DLL can itself use the VC runtime. Use the selected toolset's
# app-local redistributables when needed, even on a host with a global redist.
if ($env:VCToolsRedistDir) {
$x64 = Join-Path $env:VCToolsRedistDir 'x64'
if (Test-Path -LiteralPath $x64) {
$dllDirs += @(Get-ChildItem -LiteralPath $x64 -Directory -Filter 'Microsoft.VC*.CRT' | ForEach-Object { $_.FullName })
}
}
$packageArgs = @('packaging/package.py', 'windows', $binary, '--output', $destination, '--require-static-crt')
foreach ($dir in $dllDirs) { $packageArgs += @('--dll-dir', $dir) }
& $packagingPython @packageArgs
if ($LASTEXITCODE -ne 0) { throw "Windows packaging failed ($LASTEXITCODE)." }
& $packagingPython packaging/check_windows_release.py $destination
if ($LASTEXITCODE -ne 0) { throw "Packaged Windows executable failed verification ($LASTEXITCODE)." }
} finally {
Pop-Location
Remove-Item -LiteralPath $work.FullName -Recurse -Force -ErrorAction Continue
}
+9 -11
View File
@@ -1,5 +1,8 @@
Unicode true
!define MUI_ICON "app.ico"
!define MUI_UNICON "app.ico"
!include "MUI2.nsh"
!include "payload-files.nsh"
Name "Rusty Path of Building"
OutFile "${OUTPUT}"
@@ -24,15 +27,12 @@ FunctionEnd
Section "Rusty Path of Building"
SetShellVarContext current
SetOutPath "$INSTDIR"
File "payload\${APP}"
SetOutPath "$INSTDIR\licenses"
File "payload\licenses\LICENSE.txt"
File "payload\licenses\LiberationSans.txt"
File "payload\licenses\VeraMono.txt"
!insertmacro InstallPayload
SetOutPath "$INSTDIR"
WriteUninstaller "$INSTDIR\Uninstall.exe"
CreateShortcut "$SMPROGRAMS\Rusty Path of Building.lnk" "$INSTDIR\${APP}"
CreateShortcut "$SMPROGRAMS\Rusty Path of Building - PoE 1.lnk" "$INSTDIR\${APP}" "poe1"
CreateShortcut "$SMPROGRAMS\Rusty Path of Building - PoE 2.lnk" "$INSTDIR\${APP}" "poe2"
WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayName" "Rusty Path of Building"
WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayVersion" "${VERSION}"
WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\${APP}"
@@ -46,11 +46,9 @@ Section "Uninstall"
SetRegView 64
SetShellVarContext current
Delete "$SMPROGRAMS\Rusty Path of Building.lnk"
Delete "$INSTDIR\${APP}"
Delete "$INSTDIR\licenses\LICENSE.txt"
Delete "$INSTDIR\licenses\LiberationSans.txt"
Delete "$INSTDIR\licenses\VeraMono.txt"
RMDir "$INSTDIR\licenses"
Delete "$SMPROGRAMS\Rusty Path of Building - PoE 1.lnk"
Delete "$SMPROGRAMS\Rusty Path of Building - PoE 2.lnk"
!insertmacro UninstallPayload
Delete "$INSTDIR\Uninstall.exe"
RMDir "$INSTDIR"
DeleteRegKey HKCU "${UNINSTALL_KEY}"
+3
View File
@@ -0,0 +1,3 @@
# Windows packaging only; the universal wheel digest is from PyPI.
--only-binary=:all:
pefile==2024.8.26 --hash=sha256:76f8b485dcd3b1bb8166f1128d395fa3d87af26360c2358fb75b80019b957c6f