diff --git a/.github/workflows/windows-build-nsis.yml b/.github/workflows/windows-build-nsis.yml index a8d78d55..024e3486 100644 --- a/.github/workflows/windows-build-nsis.yml +++ b/.github/workflows/windows-build-nsis.yml @@ -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 { diff --git a/distribution/windows/installer/huntarr_installer.nsi b/distribution/windows/installer/huntarr_installer.nsi index 7af0d96c..00b12d7f 100644 --- a/distribution/windows/installer/huntarr_installer.nsi +++ b/distribution/windows/installer/huntarr_installer.nsi @@ -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"