Refine NSIS version file path handling in GHA workflow

This commit is contained in:
Huntarr Developer
2025-05-19 19:51:06 -04:00
parent 1036ef495a
commit 59d6c55e8b
2 changed files with 38 additions and 10 deletions

View File

@@ -54,13 +54,24 @@ jobs:
# Display current directory structure
dir
# Run NSIS compiler
# Prepare version file path
$versionContent = Get-Content version.txt -Raw
Write-Host "Version from file: $versionContent"
& "C:\Program Files (x86)\NSIS\makensis.exe" /DVERSIONFILE="version.txt" distribution/windows/installer/huntarr_installer.nsi
$AbsVersionFile = Join-Path -Path $PWD.Path -ChildPath "version.txt"
Write-Host "Absolute path for VERSIONFILE: $AbsVersionFile"
# Prepare arguments for makensis.exe
$MakensisArgs = @(
"/DVERSIONFILE=${AbsVersionFile}",
"distribution\windows\installer\huntarr_installer.nsi"
)
# Run NSIS compiler
Write-Host "Running makensis.exe with arguments: $MakensisArgs"
& "C:\Program Files (x86)\NSIS\makensis.exe" $MakensisArgs
# Check if installer was created
$installerPath = "installer/Huntarr_Setup.exe"
$installerPath = "installer\Huntarr_Setup.exe"
if (Test-Path $installerPath) {
Write-Host "Installer created successfully at $installerPath"
} else {

View File

@@ -4,18 +4,35 @@
!include "FileFunc.nsh"
!include "LogicLib.nsh"
; Set a default version in case the file read fails
!define DEFAULT_VERSION "1.0.0"
!verbose 4 ; Increase verbosity for debugging defines
!define DEFAULT_VERSION "1.0.0-default"
; Try to read version from file
!ifdef VERSIONFILE
!define /file VERSION "${VERSIONFILE}"
!searchreplace VERSION "${VERSION}" "\n" ""
!searchreplace VERSION "${VERSION}" "\r" ""
!echo "VERSIONFILE is defined by command line as: '${VERSIONFILE}'"
!if ${FileExists} "${VERSIONFILE}"
!define /file VERSION "${VERSIONFILE}"
!searchreplace VERSION "${VERSION}" "\n" ""
!searchreplace VERSION "${VERSION}" "\r" ""
!echo "Successfully read version '${VERSION}' from '${VERSIONFILE}'"
!else
!error "VERSIONFILE was defined as '${VERSIONFILE}', but this file was NOT FOUND! Using default version."
!define VERSION "${DEFAULT_VERSION}" ; Fallback
!endif
!else
!define VERSION "${DEFAULT_VERSION}"
!warning "VERSIONFILE was NOT defined on the command line. Trying relative 'version.txt'."
!if ${FileExists} "version.txt" ; Relative to script path, or project root if lucky
!define /file VERSION "version.txt"
!searchreplace VERSION "${VERSION}" "\n" ""
!searchreplace VERSION "${VERSION}" "\r" ""
!echo "Successfully read version '${VERSION}' from relative 'version.txt'"
!else
!warning "Relative 'version.txt' also not found. Using default version '${DEFAULT_VERSION}'."
!define VERSION "${DEFAULT_VERSION}"
!endif
!endif
!echo "Final VERSION defined as: '${VERSION}'"
; Application details
!define APPNAME "Huntarr"
!define EXENAME "Huntarr.exe"