mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-05-13 21:39:59 +02:00
205 lines
8.2 KiB
YAML
205 lines
8.2 KiB
YAML
name: Windows MSI (WiX v7)
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
run_id:
|
|
description: "Run ID de 'Windows Build' (laisse vide pour le dernier run réussi)"
|
|
required: false
|
|
default: ""
|
|
|
|
jobs:
|
|
build-msi:
|
|
name: Build MSI with WiX v7
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
|
# ----------------------------------------------------------------
|
|
# 1. Checkout (pour récupérer QElectroTech.wxs et CMakeLists.txt)
|
|
# ----------------------------------------------------------------
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
# ----------------------------------------------------------------
|
|
# 2. Télécharger l'artifact portable du build principal
|
|
# Nécessite que windows-build.yml uploade un artifact nommé
|
|
# "qelectrotech-windows-portable" (nom fixe, voir windows-build.yml)
|
|
# ----------------------------------------------------------------
|
|
- 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 }}
|
|
|
|
# ----------------------------------------------------------------
|
|
# 3. Extraire la version depuis les sources
|
|
# ----------------------------------------------------------------
|
|
- name: Extract version
|
|
id: version
|
|
shell: pwsh
|
|
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)
|
|
$verMsi = "$ver.0"
|
|
|
|
# Short SHA pour la version lisible
|
|
$sha = git rev-parse --short HEAD 2>$null
|
|
if (-not $sha) { $sha = "unknown" }
|
|
|
|
# Numéro de révision cumulatif (même calcul que 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. Installer WiX v7 via dotnet tool
|
|
# ----------------------------------------------------------------
|
|
- 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é."
|
|
|
|
# ----------------------------------------------------------------
|
|
# 5. Installer l'extension WixUI
|
|
# ----------------------------------------------------------------
|
|
- name: Install WiX UI extension
|
|
shell: pwsh
|
|
run: |
|
|
wix extension add WixToolset.UI.wixext/7.0.0 --accept-eula
|
|
Write-Host "Extension UI installée."
|
|
|
|
# ----------------------------------------------------------------
|
|
# 6. Vérifier la présence du fichier WXS dans le dépôt
|
|
# ----------------------------------------------------------------
|
|
- name: Check WXS file
|
|
shell: pwsh
|
|
run: |
|
|
$wxs = "build-aux\windows\QElectroTech.wxs"
|
|
if (-not (Test-Path $wxs)) {
|
|
Write-Error "Fichier WXS introuvable : $wxs"
|
|
Write-Host "Contenu de build-aux\windows\ :"
|
|
Get-ChildItem "build-aux\windows\" -ErrorAction SilentlyContinue
|
|
exit 1
|
|
}
|
|
Write-Host "WXS trouvé : $wxs"
|
|
|
|
# ----------------------------------------------------------------
|
|
# 7. Vérifier la structure de l'artifact et localiser files/
|
|
# ----------------------------------------------------------------
|
|
- 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
|
|
|
|
# Chercher qelectrotech.exe dans l'artifact
|
|
$exe = Get-ChildItem -Path "artifact\files" -Filter "qelectrotech.exe" -Recurse | Select-Object -First 1
|
|
if (-not $exe) {
|
|
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\ (soit artifact\files directement,
|
|
# soit un sous-dossier si l'artifact a une structure imbriquée)
|
|
$binDir = $exe.Directory.FullName
|
|
$filesDir = Split-Path $binDir -Parent
|
|
|
|
echo "FILES_DIR=$filesDir" >> $env:GITHUB_ENV
|
|
Write-Host "FILES_DIR : $filesDir"
|
|
|
|
# ----------------------------------------------------------------
|
|
# 8. 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 `
|
|
--accept-eula `
|
|
-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 ✗"
|
|
}
|