name: Windows MSI (WiX v7) on: workflow_dispatch: inputs: run_id: description: "Run ID of 'Windows Build' (leave empty for the latest successful run)" required: false default: "" jobs: build-msi: name: Build MSI with WiX v7 runs-on: windows-latest steps: # ---------------------------------------------------------------- # 1. Checkout (to retrieve QElectroTech.wxs and sources) # ---------------------------------------------------------------- - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 # ---------------------------------------------------------------- # 2. Download the portable artifact from the main build # Requires windows-build.yml to upload an artifact named # "qelectrotech-windows-portable" (fixed name) # ---------------------------------------------------------------- - name: Download portable artifact uses: actions/download-artifact@v4 with: name: qelectrotech-windows-portable path: artifact\files run-id: ${{ github.event.inputs.run_id || github.run_id }} github-token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.repository }} # ---------------------------------------------------------------- # 3. Extract version from sources # ---------------------------------------------------------------- - name: Extract version id: version shell: pwsh run: | # Version from qetversion.cpp (same logic as windows-build.yml) $src = Get-Content "sources\qetversion.cpp" -Raw -ErrorAction SilentlyContinue if ($src -match 'return QVersionNumber\{([^}]+)\}') { $ver = $Matches[1] -replace '\s','' -replace ',','.' } else { # Fallback: CMakeLists.txt $cmake = Get-Content "CMakeLists.txt" -Raw if ($cmake -match 'project\s*\([^)]*VERSION\s+([\d]+\.[\d]+\.[\d]+)') { $ver = $Matches[1] } else { $ver = "0.0.0" } } # Numeric MSI version: 4 digits required (e.g. 0.100.1.0) $verMsi = "$ver.0" # Short SHA for the display version $sha = git rev-parse --short HEAD 2>$null if (-not $sha) { $sha = "unknown" } # Cumulative revision number (same calculation as windows-build.yml) $count = git rev-list HEAD --count 2>$null $rev = [int]$count + 473 $verDisplay = "${ver}-r${rev}-${sha}_x86_64-win64" echo "VERSION_MSI=$verMsi" >> $env:GITHUB_OUTPUT echo "VERSION_DISPLAY=$verDisplay" >> $env:GITHUB_OUTPUT Write-Host "Version MSI : $verMsi" Write-Host "Version display : $verDisplay" # ---------------------------------------------------------------- # 4. Install WiX v7, accept EULA and install WixUI extension # All done in one step: PATH is updated within the same step # so wix is immediately available for eula and extension commands # ---------------------------------------------------------------- - name: Install WiX v7 shell: pwsh run: | dotnet tool install --global wix --version 7.0.0 # Update PATH immediately for the rest of this step $toolsPath = [System.IO.Path]::Combine($env:USERPROFILE, '.dotnet', 'tools') $env:PATH = "$toolsPath;$env:PATH" # Also export for subsequent steps echo $toolsPath >> $env:GITHUB_PATH # Accept OSMF EULA (official CI/CD method: writes a sentinel file) wix eula accept wix7 # Install WixUI extension wix extension add WixToolset.UI.wixext/7.0.0 Write-Host "WiX v7 installed, EULA accepted, UI extension added." # ---------------------------------------------------------------- # 5. Check that the WXS file exists in the repository # ---------------------------------------------------------------- - name: Check WXS file shell: pwsh run: | $wxs = "build-aux\windows\QElectroTech.wxs" if (-not (Test-Path $wxs)) { Write-Error "WXS file not found: $wxs" Write-Host "Contents of build-aux\windows\ :" Get-ChildItem "build-aux\windows\" -ErrorAction SilentlyContinue exit 1 } Write-Host "WXS found: $wxs" # ---------------------------------------------------------------- # 6. Check the artifact structure and locate files/ # ---------------------------------------------------------------- - name: Check artifact structure shell: pwsh run: | Write-Host "=== Contents of artifact\files (2 levels) ===" Get-ChildItem -Path "artifact\files" -Depth 2 | Select-Object FullName | Format-Table -AutoSize # Search for qelectrotech.exe in the artifact $exe = Get-ChildItem -Path "artifact\files" -Filter "qelectrotech.exe" -Recurse | Select-Object -First 1 if (-not $exe) { Write-Error "qelectrotech.exe not found in artifact" exit 1 } Write-Host "Executable: $($exe.FullName) ($([math]::Round($exe.Length/1MB,1)) MB)" # FilesDir = folder containing bin\ $binDir = $exe.Directory.FullName $filesDir = Split-Path $binDir -Parent echo "FILES_DIR=$filesDir" >> $env:GITHUB_ENV Write-Host "FILES_DIR: $filesDir" # ---------------------------------------------------------------- # 7. Build the MSI # ---------------------------------------------------------------- - name: Build MSI shell: pwsh run: | $version = "${{ steps.version.outputs.VERSION_MSI }}" $verDisplay = "${{ steps.version.outputs.VERSION_DISPLAY }}" $filesDir = $env:FILES_DIR $wxs = "build-aux\windows\QElectroTech.wxs" $outputName = "QElectroTech-${verDisplay}.msi" New-Item -ItemType Directory -Force -Path "dist" | Out-Null Write-Host "=== wix build ===" Write-Host " WXS : $wxs" Write-Host " Version : $version" Write-Host " FilesDir : $filesDir" Write-Host " Output : dist\$outputName" wix build $wxs ` -arch x64 ` -d "Version=$version" ` -d "ProductVersion=$verDisplay" ` -d "FilesDir=$filesDir" ` -ext WixToolset.UI.wixext ` -o "dist\$outputName" if (-not (Test-Path "dist\$outputName")) { Write-Error "MSI not generated: dist\$outputName" exit 1 } $size = [math]::Round((Get-Item "dist\$outputName").Length / 1MB, 1) Write-Host "MSI generated: dist\$outputName ($size MB) ✓" echo "MSI_NAME=$outputName" >> $env:GITHUB_ENV # ---------------------------------------------------------------- # 8. Upload the MSI artifact # ---------------------------------------------------------------- - name: Upload MSI artifact uses: actions/upload-artifact@v4 with: name: qelectrotech-windows-msi path: dist\*.msi retention-days: 14 if-no-files-found: error # ---------------------------------------------------------------- # 9. Summary # ---------------------------------------------------------------- - name: Summary if: always() shell: pwsh run: | Write-Host "=== MSI build summary ===" Write-Host "Version : ${{ steps.version.outputs.VERSION_DISPLAY }}" Write-Host "WiX : v7.0.0" Write-Host "Runner image : ${{ runner.os }} / ${{ runner.arch }}" if (Test-Path "dist\$env:MSI_NAME") { $size = [math]::Round((Get-Item "dist\$env:MSI_NAME").Length / 1MB, 1) Write-Host "MSI : $env:MSI_NAME ($size MB) ✓" } else { Write-Host "MSI : FAILED ✗" }