mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-05-14 14:49:59 +02:00
Update windows-msi.yml
This commit is contained in:
322
.github/workflows/windows-msi.yml
vendored
322
.github/workflows/windows-msi.yml
vendored
@@ -1,152 +1,208 @@
|
|||||||
<?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 (pour récupérer QElectroTech.wxs et les sources)
|
||||||
Schedule="afterInstallInitialize" />
|
# ----------------------------------------------------------------
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
<!-- Répertoire d'installation -->
|
# ----------------------------------------------------------------
|
||||||
<StandardDirectory Id="ProgramFiles64Folder">
|
# 2. Télécharger l'artifact portable du build principal
|
||||||
<Directory Id="INSTALLDIR" Name="QElectroTech" />
|
# Nécessite que windows-build.yml uploade un artifact nommé
|
||||||
</StandardDirectory>
|
# "qelectrotech-windows-portable" (nom fixe)
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- 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.event.inputs.run_id || github.run_id }}
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
repository: ${{ github.repository }}
|
||||||
|
|
||||||
<!-- ============================================================
|
# ----------------------------------------------------------------
|
||||||
bin\ complet (exe + toutes les DLLs + sous-dossiers Qt)
|
# 3. Extraire la version depuis les sources
|
||||||
Files harvest tout le dossier — pas d'attribut Exclude en WiX v7
|
# ----------------------------------------------------------------
|
||||||
============================================================ -->
|
- name: Extract version
|
||||||
<ComponentGroup Id="CG_Bin" Directory="INSTALLDIR">
|
id: version
|
||||||
<Files Include="!(bind.Variable.FilesDir)\bin\**" />
|
shell: pwsh
|
||||||
</ComponentGroup>
|
run: |
|
||||||
|
# Version depuis qetversion.cpp (même logique que 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<!-- ============================================================
|
# Version numérique MSI : 4 chiffres obligatoire (ex. 0.100.1.0)
|
||||||
Fichiers racine de files\ (LICENSE, bat, reg...)
|
$verMsi = "$ver.0"
|
||||||
============================================================ -->
|
|
||||||
<ComponentGroup Id="CG_Root" Directory="INSTALLDIR">
|
|
||||||
<Files Include="!(bind.Variable.FilesDir)\*" />
|
|
||||||
</ComponentGroup>
|
|
||||||
|
|
||||||
<!-- ============================================================
|
# Short SHA pour la version lisible
|
||||||
Données applicatives — harvest 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">
|
# Numéro de révision cumulatif (même calcul que 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. Installer l'extension WixUI
|
||||||
</ComponentGroup>
|
# WIX_ACCEPT_EULA=true est la méthode officielle pour accepter
|
||||||
|
# la licence OSMF de WiX v7 en environnement CI
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- name: Install WiX UI extension
|
||||||
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
WIX_ACCEPT_EULA: true
|
||||||
|
run: |
|
||||||
|
wix extension add WixToolset.UI.wixext/7.0.0
|
||||||
|
Write-Host "Extension UI installée."
|
||||||
|
|
||||||
<!-- ============================================================
|
# ----------------------------------------------------------------
|
||||||
Raccourcis bureau + menu Démarrer
|
# 6. Vérifier la présence du fichier WXS dans le dépôt
|
||||||
============================================================ -->
|
# ----------------------------------------------------------------
|
||||||
<ComponentGroup Id="CG_Shortcuts" Directory="INSTALLDIR">
|
- name: Check WXS file
|
||||||
<Component Id="C_ShortcutDesktop" Guid="F1A2B3C4-D5E6-7890-5678-012345678901">
|
shell: pwsh
|
||||||
<Shortcut Id="DesktopShortcut"
|
run: |
|
||||||
Directory="DesktopFolder"
|
$wxs = "build-aux\windows\QElectroTech.wxs"
|
||||||
Name="QElectroTech"
|
if (-not (Test-Path $wxs)) {
|
||||||
Target="[INSTALLDIR]Lancer QET.bat"
|
Write-Error "Fichier WXS introuvable : $wxs"
|
||||||
Icon="qet.ico"
|
Write-Host "Contenu de build-aux\windows\ :"
|
||||||
WorkingDirectory="INSTALLDIR" />
|
Get-ChildItem "build-aux\windows\" -ErrorAction SilentlyContinue
|
||||||
<RegistryValue Root="HKCU"
|
exit 1
|
||||||
Key="Software\QElectroTech"
|
}
|
||||||
Name="DesktopShortcut"
|
Write-Host "WXS trouvé : $wxs"
|
||||||
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. Vérifier la structure de l'artifact et localiser files/
|
||||||
============================================================ -->
|
# ----------------------------------------------------------------
|
||||||
<ComponentGroup Id="CG_FileAssoc" Directory="INSTALLDIR">
|
- name: Check artifact structure
|
||||||
<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" />
|
Write-Host "=== Contenu de artifact\files (2 niveaux) ==="
|
||||||
<RegistryValue Root="HKCR" Key="QElectroTech.Document\DefaultIcon" Type="string"
|
Get-ChildItem -Path "artifact\files" -Depth 2 |
|
||||||
Value="[INSTALLDIR]ico\qelectrotech.ico" />
|
Select-Object FullName | Format-Table -AutoSize
|
||||||
<RegistryValue Root="HKCR" Key="QElectroTech.Document\shell\open\command" Type="string"
|
|
||||||
Value=""[INSTALLDIR]bin\qelectrotech.exe" "%1"" />
|
|
||||||
</Component>
|
|
||||||
</ComponentGroup>
|
|
||||||
|
|
||||||
<!-- ============================================================
|
# Chercher qelectrotech.exe dans l'artifact
|
||||||
Icône pour les raccourcis
|
$exe = Get-ChildItem -Path "artifact\files" -Filter "qelectrotech.exe" -Recurse | Select-Object -First 1
|
||||||
============================================================ -->
|
if (-not $exe) {
|
||||||
<Icon Id="qet.ico" SourceFile="!(bind.Variable.FilesDir)\ico\qelectrotech.ico" />
|
Write-Error "qelectrotech.exe introuvable dans l'artifact"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
Write-Host "Executable : $($exe.FullName) ($([math]::Round($exe.Length/1MB,1)) MB)"
|
||||||
|
|
||||||
<!-- ============================================================
|
# FilesDir = dossier contenant bin\
|
||||||
Feature principale (tout inclus)
|
$binDir = $exe.Directory.FullName
|
||||||
============================================================ -->
|
$filesDir = Split-Path $binDir -Parent
|
||||||
<Feature Id="ProductFeature" Title="QElectroTech" Level="1">
|
|
||||||
<ComponentGroupRef Id="CG_Bin" />
|
|
||||||
<ComponentGroupRef Id="CG_Root" />
|
|
||||||
<ComponentGroupRef Id="CG_Elements" />
|
|
||||||
<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 -->
|
echo "FILES_DIR=$filesDir" >> $env:GITHUB_ENV
|
||||||
<UIRef Id="WixUI_Minimal" />
|
Write-Host "FILES_DIR : $filesDir"
|
||||||
|
|
||||||
<!-- Propriétés affichées dans Programmes et fonctionnalités -->
|
# ----------------------------------------------------------------
|
||||||
<Property Id="ARPPRODUCTICON" Value="qet.ico" />
|
# 8. Construire le MSI
|
||||||
<Property Id="ARPHELPLINK" Value="https://qelectrotech.org" />
|
# ----------------------------------------------------------------
|
||||||
<Property Id="ARPURLINFOABOUT" Value="https://qelectrotech.org" />
|
- name: Build MSI
|
||||||
<Property Id="ARPCOMMENTS" Value="Logiciel libre de schémas électriques" />
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
WIX_ACCEPT_EULA: true
|
||||||
|
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"
|
||||||
|
|
||||||
</Package>
|
New-Item -ItemType Directory -Force -Path "dist" | Out-Null
|
||||||
</Wix>
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# 9. 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
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# 10. Résumé
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- 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