Skip to content

Commit e122994

Browse files
committed
updated workflow for installer
1 parent 188e31f commit e122994

2 files changed

Lines changed: 20 additions & 30 deletions

File tree

.github/workflows/build-launcher-installer.yml

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ jobs:
4848
4949
- name: Create installer script
5050
run: |
51-
$installerScript = @'
51+
# Create the installer script by writing it directly to avoid nested here-string issues
52+
$scriptContent = @"
5253
# Woodlanders Launcher - Windows Installer with JRE Auto-Download
5354
# Auto-generated installer script
5455
@@ -171,30 +172,8 @@ jobs:
171172
}
172173
173174
function Create-LauncherScript {
174-
$launcherScript = @'
175-
@echo off
176-
setlocal
177-
178-
set "APP_DIR=%~dp0"
179-
set "JAVAFX_CACHE=%USERPROFILE%\.cache\woodlanders-javafx"
180-
181-
if exist "%APP_DIR%jre\bin\java.exe" (
182-
set "JAVA_CMD=%APP_DIR%jre\bin\java.exe"
183-
) else (
184-
set "JAVA_CMD=java"
185-
)
186-
187-
"%JAVA_CMD%" -Djavafx.cachedir="%JAVAFX_CACHE%" -jar "%APP_DIR%woodlanders-launcher.jar"
188-
if %ERRORLEVEL% neq 0 (
189-
echo.
190-
echo Application failed to start.
191-
pause
192-
)
193-
194-
endlocal
195-
'@
196-
197-
$launcherScript | Out-File -FilePath "$INSTALL_DIR\launcher.bat" -Encoding ASCII -Force
175+
`$batContent = "@echo off``r``nsetlocal``r``nset APP_DIR=%~dp0``r``nset JAVAFX_CACHE=%USERPROFILE%\.cache\woodlanders-javafx``r``nif exist %APP_DIR%jre\bin\java.exe (set JAVA_CMD=%APP_DIR%jre\bin\java.exe) else (set JAVA_CMD=java)``r``n%JAVA_CMD% -Djavafx.cachedir=%JAVAFX_CACHE% -jar %APP_DIR%woodlanders-launcher.jar``r``nif %ERRORLEVEL% neq 0 (echo. & echo Application failed to start. & pause)``r``nendlocal"
176+
`$batContent | Out-File -FilePath "`$INSTALL_DIR\launcher.bat" -Encoding ASCII -Force
198177
Write-Success "Launcher script created"
199178
}
200179
@@ -282,9 +261,12 @@ jobs:
282261
}
283262
exit 1
284263
}
285-
'@
264+
"@
265+
266+
# Fix the scriptDir line for ps2exe compatibility
267+
$scriptContent = $scriptContent -replace '\`$scriptDir = if \(\`$PSScriptRoot\) \{ \`$PSScriptRoot \} else \{ Split-Path -Parent \`$MyInvocation\.MyCommand\.Path \}', '`$scriptDir = if ($PSScriptRoot) { $PSScriptRoot } elseif ($MyInvocation.MyCommand.Path) { Split-Path -Parent $MyInvocation.MyCommand.Path } else { Get-Location | Select-Object -ExpandProperty Path }'
286268
287-
$installerScript | Out-File -FilePath installer-staging\install.ps1 -Encoding UTF8
269+
$scriptContent | Out-File -FilePath installer-staging\install.ps1 -Encoding UTF8
288270
289271
- name: Create README for installer
290272
run: |

specs/launcher-installer-implementation.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,15 @@ The release workflow now includes:
9393

9494
**Solution:** Created `Main.java` wrapper class that calls `LauncherApplication.launch()` instead of extending Application.
9595

96-
### Challenge 2: ps2exe Script Directory
96+
### Challenge 2: Nested Here-Strings in GitHub Actions
97+
**Issue:** GitHub Actions PowerShell runner fails when there are nested here-strings (a here-string inside another here-string).
98+
99+
**Solution:**
100+
- Changed outer here-string from `@'...'@` to `@"..."@` to allow variable expansion
101+
- Replaced inner here-string (batch script) with inline string using escape sequences
102+
- Applied regex replacement to fix `$scriptDir` after script creation
103+
104+
### Challenge 3: ps2exe Script Directory
97105
**Issue:** When PowerShell script is compiled to EXE with ps2exe, `$PSScriptRoot` and `$MyInvocation.MyCommand.Path` become null.
98106

99107
**Solution:** Added fallback to `Get-Location` for compiled EXE:
@@ -103,15 +111,15 @@ $scriptDir = if ($PSScriptRoot) { $PSScriptRoot }
103111
else { Get-Location | Select-Object -ExpandProperty Path }
104112
```
105113

106-
### Challenge 3: Icon Format
114+
### Challenge 4: Icon Format
107115
**Issue:** ps2exe requires ICO format, but we have PNG.
108116

109117
**Solution:**
110118
- Renamed PNG to `.ico` extension (Windows shortcuts accept PNG with .ico extension)
111119
- Removed icon parameter from ps2exe (not needed for installer EXE)
112120
- Icon is used for shortcuts after installation
113121

114-
### Challenge 4: EXE File Dependencies
122+
### Challenge 5: EXE File Dependencies
115123
**Issue:** ps2exe doesn't embed large files like JAR into the EXE.
116124

117125
**Solution:**

0 commit comments

Comments
 (0)