mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-05-14 22:59:59 +02:00
Update QElectroTech.wxs
This commit is contained in:
@@ -1,167 +1,213 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
name: Windows MSI (WiX v7)
|
||||||
<!--
|
|
||||||
QElectroTech.wxs — WiX v7 installer definition
|
|
||||||
Génère un MSI x64 pour QElectroTech (build MSYS2/UCRT64).
|
|
||||||
|
|
||||||
Variables passées depuis la ligne de commande wix build :
|
on:
|
||||||
-d FilesDir=<chemin absolu vers artifact\files>
|
workflow_dispatch:
|
||||||
-d Version=<version numérique ex. 0.100.1.0>
|
inputs:
|
||||||
-d ProductVersion=<version lisible ex. 0.100.1-r8770-abc1234_x86_64-win64>
|
run_id:
|
||||||
-->
|
description: "Run ID de 'Windows Build' (laisse vide pour le dernier run réussi)"
|
||||||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
|
required: false
|
||||||
|
default: ""
|
||||||
|
|
||||||
<Package
|
jobs:
|
||||||
Name="QElectroTech"
|
build-msi:
|
||||||
Manufacturer="QElectroTech Team"
|
name: Build MSI with WiX v7
|
||||||
Version="!(bind.Variable.Version)"
|
runs-on: windows-latest
|
||||||
UpgradeCode="A1B2C3D4-E5F6-7890-ABCD-EF1234567890"
|
|
||||||
Language="1033"
|
|
||||||
Codepage="1252"
|
|
||||||
InstallerVersion="500"
|
|
||||||
Scope="perMachine">
|
|
||||||
|
|
||||||
<!-- Mise à jour en place : désinstalle l'ancienne version automatiquement -->
|
steps:
|
||||||
<MajorUpgrade
|
# ----------------------------------------------------------------
|
||||||
DowngradeErrorMessage="Une version plus récente de QElectroTech est déjà installée."
|
# 1. Checkout (to retrieve QElectroTech.wxs and sources)
|
||||||
Schedule="afterInstallInitialize" />
|
# ----------------------------------------------------------------
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
<!-- Répertoire d'installation -->
|
# ----------------------------------------------------------------
|
||||||
<StandardDirectory Id="ProgramFiles64Folder">
|
# 2. Download the portable artifact from the main build
|
||||||
<Directory Id="INSTALLDIR" Name="QElectroTech" />
|
# Requires windows-build.yml to upload an artifact named
|
||||||
</StandardDirectory>
|
# "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 }}
|
||||||
|
|
||||||
<!-- ============================================================
|
# ----------------------------------------------------------------
|
||||||
Exe principal + bat lanceur
|
# 3. Extraire la version depuis les sources
|
||||||
============================================================ -->
|
# ----------------------------------------------------------------
|
||||||
<ComponentGroup Id="CG_Exe" Directory="INSTALLDIR">
|
- name: Extract version
|
||||||
<Component Id="C_MainExe" Guid="B1C2D3E4-F5A6-7890-BCDE-F12345678901">
|
id: version
|
||||||
<File Id="qelectrotech_exe"
|
shell: pwsh
|
||||||
Source="!(bind.Variable.FilesDir)\bin\qelectrotech.exe"
|
run: |
|
||||||
KeyPath="yes" />
|
# Version from qetversion.cpp (same logic as windows-build.yml)
|
||||||
</Component>
|
$src = Get-Content "sources\qetversion.cpp" -Raw -ErrorAction SilentlyContinue
|
||||||
<Component Id="C_LauncherBat" Guid="C2D3E4F5-A6B7-8901-CDEF-123456789012">
|
if ($src -match 'return QVersionNumber\{([^}]+)\}') {
|
||||||
<File Id="lancer_qet_bat"
|
$ver = $Matches[1] -replace '\s','' -replace ',','.'
|
||||||
Source="!(bind.Variable.FilesDir)\Lancer QET.bat"
|
} else {
|
||||||
KeyPath="yes" />
|
# Fallback: CMakeLists.txt
|
||||||
</Component>
|
$cmake = Get-Content "CMakeLists.txt" -Raw
|
||||||
<Component Id="C_License" Guid="E0F1A2B3-C4D5-6789-4567-901234567890">
|
if ($cmake -match 'project\s*\([^)]*VERSION\s+([\d]+\.[\d]+\.[\d]+)') {
|
||||||
<File Id="LICENSE"
|
$ver = $Matches[1]
|
||||||
Source="!(bind.Variable.FilesDir)\LICENSE"
|
} else {
|
||||||
KeyPath="yes" />
|
$ver = "0.0.0"
|
||||||
</Component>
|
}
|
||||||
</ComponentGroup>
|
}
|
||||||
|
|
||||||
<!-- ============================================================
|
# Numeric MSI version: 4 digits required (e.g. 0.100.1.0)
|
||||||
DLLs et sous-dossiers de bin\ (harvest automatique)
|
$verMsi = "$ver.0"
|
||||||
En WiX v7, Files est enfant direct de ComponentGroup
|
|
||||||
============================================================ -->
|
|
||||||
<ComponentGroup Id="CG_Bin" Directory="INSTALLDIR">
|
|
||||||
<Files Include="!(bind.Variable.FilesDir)\bin\**"
|
|
||||||
Exclude="!(bind.Variable.FilesDir)\bin\qelectrotech.exe" />
|
|
||||||
</ComponentGroup>
|
|
||||||
|
|
||||||
<!-- ============================================================
|
# Short SHA for the display version
|
||||||
Données applicatives — harvest automatique par dossier
|
$sha = git rev-parse --short HEAD 2>$null
|
||||||
============================================================ -->
|
if (-not $sha) { $sha = "unknown" }
|
||||||
<ComponentGroup Id="CG_Elements" Directory="INSTALLDIR">
|
|
||||||
<Files Include="!(bind.Variable.FilesDir)\elements\**" />
|
|
||||||
</ComponentGroup>
|
|
||||||
|
|
||||||
<ComponentGroup Id="CG_Lang" Directory="INSTALLDIR">
|
# Cumulative revision number (same calculation as windows-build.yml)
|
||||||
<Files Include="!(bind.Variable.FilesDir)\lang\**" />
|
$count = git rev-list HEAD --count 2>$null
|
||||||
</ComponentGroup>
|
$rev = [int]$count + 473
|
||||||
|
|
||||||
<ComponentGroup Id="CG_Titleblocks" Directory="INSTALLDIR">
|
$verDisplay = "${ver}-r${rev}-${sha}_x86_64-win64"
|
||||||
<Files Include="!(bind.Variable.FilesDir)\titleblocks\**" />
|
|
||||||
</ComponentGroup>
|
|
||||||
|
|
||||||
<ComponentGroup Id="CG_Examples" Directory="INSTALLDIR">
|
echo "VERSION_MSI=$verMsi" >> $env:GITHUB_OUTPUT
|
||||||
<Files Include="!(bind.Variable.FilesDir)\examples\**" />
|
echo "VERSION_DISPLAY=$verDisplay" >> $env:GITHUB_OUTPUT
|
||||||
</ComponentGroup>
|
Write-Host "Version MSI : $verMsi"
|
||||||
|
Write-Host "Version display : $verDisplay"
|
||||||
|
|
||||||
<ComponentGroup Id="CG_Fonts" Directory="INSTALLDIR">
|
# ----------------------------------------------------------------
|
||||||
<Files Include="!(bind.Variable.FilesDir)\fonts\**" />
|
# 4. Installer WiX v7 via dotnet tool
|
||||||
</ComponentGroup>
|
# ----------------------------------------------------------------
|
||||||
|
- name: Install WiX v7
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
dotnet tool install --global wix --version 7.0.0
|
||||||
|
$toolsPath = [System.IO.Path]::Combine($env:USERPROFILE, '.dotnet', 'tools')
|
||||||
|
echo $toolsPath >> $env:GITHUB_PATH
|
||||||
|
Write-Host "WiX v7 installé."
|
||||||
|
|
||||||
<ComponentGroup Id="CG_Icons" Directory="INSTALLDIR">
|
# ----------------------------------------------------------------
|
||||||
<Files Include="!(bind.Variable.FilesDir)\ico\**" />
|
# 5. Accepter la licence OSMF WiX v7
|
||||||
</ComponentGroup>
|
# Official CI/CD method: writes a sentinel file
|
||||||
|
# that authorises all subsequent wix commands in the job
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- name: Accept WiX EULA
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
wix eula accept wix7
|
||||||
|
Write-Host "EULA WiX v7 acceptée."
|
||||||
|
|
||||||
<!-- ============================================================
|
# ----------------------------------------------------------------
|
||||||
Raccourcis bureau + menu Démarrer
|
# 6. Installer l'extension WixUI
|
||||||
============================================================ -->
|
# ----------------------------------------------------------------
|
||||||
<ComponentGroup Id="CG_Shortcuts" Directory="INSTALLDIR">
|
- name: Install WiX UI extension
|
||||||
<Component Id="C_ShortcutDesktop" Guid="F1A2B3C4-D5E6-7890-5678-012345678901">
|
shell: pwsh
|
||||||
<Shortcut Id="DesktopShortcut"
|
run: |
|
||||||
Directory="DesktopFolder"
|
wix extension add WixToolset.UI.wixext/7.0.0
|
||||||
Name="QElectroTech"
|
Write-Host "Extension UI installée."
|
||||||
Target="[INSTALLDIR]Lancer QET.bat"
|
|
||||||
Icon="qet.ico"
|
|
||||||
WorkingDirectory="INSTALLDIR" />
|
|
||||||
<RegistryValue Root="HKCU"
|
|
||||||
Key="Software\QElectroTech"
|
|
||||||
Name="DesktopShortcut"
|
|
||||||
Type="integer" Value="1"
|
|
||||||
KeyPath="yes" />
|
|
||||||
</Component>
|
|
||||||
<Component Id="C_ShortcutStartMenu" Guid="A2B3C4D5-E6F7-8901-6789-123456789012">
|
|
||||||
<Shortcut Id="StartMenuShortcut"
|
|
||||||
Directory="ProgramMenuFolder"
|
|
||||||
Name="QElectroTech"
|
|
||||||
Target="[INSTALLDIR]Lancer QET.bat"
|
|
||||||
Icon="qet.ico"
|
|
||||||
WorkingDirectory="INSTALLDIR" />
|
|
||||||
<RegistryValue Root="HKCU"
|
|
||||||
Key="Software\QElectroTech"
|
|
||||||
Name="StartMenuShortcut"
|
|
||||||
Type="integer" Value="1"
|
|
||||||
KeyPath="yes" />
|
|
||||||
</Component>
|
|
||||||
</ComponentGroup>
|
|
||||||
|
|
||||||
<!-- ============================================================
|
# ----------------------------------------------------------------
|
||||||
Association fichier .qet
|
# 7. Check that the WXS file exists in the repository
|
||||||
============================================================ -->
|
# ----------------------------------------------------------------
|
||||||
<ComponentGroup Id="CG_FileAssoc" Directory="INSTALLDIR">
|
- name: Check WXS file
|
||||||
<Component Id="C_FileAssoc" Guid="B3C4D5E6-F7A8-9012-7890-234567890123">
|
shell: pwsh
|
||||||
<RegistryValue Root="HKCR" Key=".qet" Type="string" Value="QElectroTech.Document" KeyPath="yes" />
|
run: |
|
||||||
<RegistryValue Root="HKCR" Key="QElectroTech.Document" Type="string" Value="QElectroTech Project" />
|
$wxs = "build-aux\windows\QElectroTech.wxs"
|
||||||
<RegistryValue Root="HKCR" Key="QElectroTech.Document\DefaultIcon" Type="string"
|
if (-not (Test-Path $wxs)) {
|
||||||
Value="[INSTALLDIR]ico\qelectrotech.ico" />
|
Write-Error "Fichier WXS introuvable : $wxs"
|
||||||
<RegistryValue Root="HKCR" Key="QElectroTech.Document\shell\open\command" Type="string"
|
Write-Host "Contenu de build-aux\windows\ :"
|
||||||
Value=""[INSTALLDIR]bin\qelectrotech.exe" "%1"" />
|
Get-ChildItem "build-aux\windows\" -ErrorAction SilentlyContinue
|
||||||
</Component>
|
exit 1
|
||||||
</ComponentGroup>
|
}
|
||||||
|
Write-Host "WXS trouvé : $wxs"
|
||||||
|
|
||||||
<!-- ============================================================
|
# ----------------------------------------------------------------
|
||||||
Icône pour les raccourcis
|
# 8. Check the artifact structure and locate files/
|
||||||
============================================================ -->
|
# ----------------------------------------------------------------
|
||||||
<Icon Id="qet.ico" SourceFile="!(bind.Variable.FilesDir)\ico\qelectrotech.ico" />
|
- name: Check artifact structure
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
Write-Host "=== Contenu de artifact\files (2 niveaux) ==="
|
||||||
|
Get-ChildItem -Path "artifact\files" -Depth 2 |
|
||||||
|
Select-Object FullName | Format-Table -AutoSize
|
||||||
|
|
||||||
<!-- ============================================================
|
# Search for qelectrotech.exe in the artifact
|
||||||
Feature principale (tout inclus)
|
$exe = Get-ChildItem -Path "artifact\files" -Filter "qelectrotech.exe" -Recurse | Select-Object -First 1
|
||||||
============================================================ -->
|
if (-not $exe) {
|
||||||
<Feature Id="ProductFeature" Title="QElectroTech" Level="1">
|
Write-Error "qelectrotech.exe introuvable dans l'artifact"
|
||||||
<ComponentGroupRef Id="CG_Exe" />
|
exit 1
|
||||||
<ComponentGroupRef Id="CG_Bin" />
|
}
|
||||||
<ComponentGroupRef Id="CG_Elements" />
|
Write-Host "Executable : $($exe.FullName) ($([math]::Round($exe.Length/1MB,1)) MB)"
|
||||||
<ComponentGroupRef Id="CG_Lang" />
|
|
||||||
<ComponentGroupRef Id="CG_Titleblocks" />
|
|
||||||
<ComponentGroupRef Id="CG_Examples" />
|
|
||||||
<ComponentGroupRef Id="CG_Fonts" />
|
|
||||||
<ComponentGroupRef Id="CG_Icons" />
|
|
||||||
<ComponentGroupRef Id="CG_Shortcuts" />
|
|
||||||
<ComponentGroupRef Id="CG_FileAssoc" />
|
|
||||||
</Feature>
|
|
||||||
|
|
||||||
<!-- UI minimale Windows Installer -->
|
# FilesDir = folder containing bin\
|
||||||
<UIRef Id="WixUI_Minimal" />
|
$binDir = $exe.Directory.FullName
|
||||||
|
$filesDir = Split-Path $binDir -Parent
|
||||||
|
|
||||||
<!-- Propriétés affichées dans Programmes et fonctionnalités -->
|
echo "FILES_DIR=$filesDir" >> $env:GITHUB_ENV
|
||||||
<Property Id="ARPPRODUCTICON" Value="qet.ico" />
|
Write-Host "FILES_DIR : $filesDir"
|
||||||
<Property Id="ARPHELPLINK" Value="https://qelectrotech.org" />
|
|
||||||
<Property Id="ARPURLINFOABOUT" Value="https://qelectrotech.org" />
|
|
||||||
<Property Id="ARPCOMMENTS" Value="Logiciel libre de schémas électriques" />
|
|
||||||
|
|
||||||
</Package>
|
# ----------------------------------------------------------------
|
||||||
</Wix>
|
# 9. Construire le 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 non généré : dist\$outputName"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = [math]::Round((Get-Item "dist\$outputName").Length / 1MB, 1)
|
||||||
|
Write-Host "MSI généré : dist\$outputName ($size MB) ✓"
|
||||||
|
echo "MSI_NAME=$outputName" >> $env:GITHUB_ENV
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# 10. Upload de l'artifact MSI
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- 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
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# 11. Summary
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- name: Summary
|
||||||
|
if: always()
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
Write-Host "=== Résumé build MSI ==="
|
||||||
|
Write-Host "Version : ${{ steps.version.outputs.VERSION_DISPLAY }}"
|
||||||
|
Write-Host "WiX : v7.0.0"
|
||||||
|
Write-Host "Image runner : ${{ 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 : ÉCHEC ✗"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user