mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-05-13 05:10:04 +02:00
Try to build Windows msi files
This commit is contained in:
216
.github/workflows/windows-msi.yml
vendored
Normal file
216
.github/workflows/windows-msi.yml
vendored
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
name: Windows MSI (WiX v4)
|
||||||
|
|
||||||
|
# Ce workflow génère un installeur MSI pour QElectroTech.
|
||||||
|
# Il s'appuie sur l'artifact produit par le job build-windows
|
||||||
|
# (workflow windows-build.yml) et ne recompile pas le projet.
|
||||||
|
#
|
||||||
|
# Déclenchement :
|
||||||
|
# - Automatiquement après un run réussi de windows-build.yml
|
||||||
|
# - Manuellement (workflow_dispatch) pour tester
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: ["Windows build"] # doit correspondre exactement au "name:" de windows-build.yml
|
||||||
|
types: [completed]
|
||||||
|
branches: [master]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
run_id:
|
||||||
|
description: "Run ID de windows-build.yml (laisse vide pour le dernier)"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-msi:
|
||||||
|
name: Build MSI with WiX v4
|
||||||
|
runs-on: windows-latest
|
||||||
|
# Ne tourne que si le build principal a réussi (ignoré en workflow_dispatch)
|
||||||
|
if: >
|
||||||
|
github.event_name == 'workflow_dispatch' ||
|
||||||
|
github.event.workflow_run.conclusion == 'success'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# 1. Checkout (pour récupérer QElectroTech.wxs)
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# 2. Télécharger l'artifact du build principal
|
||||||
|
# L'artifact "qelectrotech-windows-installer-files" doit contenir
|
||||||
|
# le dossier nsis_root/files/ (portable build).
|
||||||
|
# Adapter le nom si nécessaire.
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- name: Download build artifact (portable files)
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: qelectrotech-windows-portable # nom de l'artifact dans windows-build.yml
|
||||||
|
path: artifact\files
|
||||||
|
# Si déclenchement manuel avec run_id précisé :
|
||||||
|
run-id: ${{ github.event.inputs.run_id || github.event.workflow_run.id }}
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# 3. Lire la version depuis l'artifact ou le dépôt
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- name: Extract version
|
||||||
|
id: version
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
# Lire la version dans 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)
|
||||||
|
$verMsi = "$ver.0"
|
||||||
|
|
||||||
|
# Version lisible avec git short SHA
|
||||||
|
$sha = git rev-parse --short HEAD 2>$null
|
||||||
|
if (-not $sha) { $sha = "unknown" }
|
||||||
|
$verDisplay = "$ver+git$sha"
|
||||||
|
|
||||||
|
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 v4 via dotnet tool
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- name: Install WiX v4
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
dotnet tool install --global wix --version 4.*
|
||||||
|
# Ajouter le chemin tools au PATH pour la session
|
||||||
|
$toolsPath = [System.IO.Path]::Combine($env:USERPROFILE, '.dotnet', 'tools')
|
||||||
|
echo $toolsPath >> $env:GITHUB_PATH
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# 5. Installer l'extension WixUI (interface graphique MSI)
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- name: Install WiX UI extension
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
wix extension add WixToolset.UI.wixext/4.*
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# 6. Copier QElectroTech.wxs depuis build-aux/windows/
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- name: Prepare WXS file
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
# Le fichier .wxs est versionné dans le dépôt
|
||||||
|
$wxs = "build-aux\windows\QElectroTech.wxs"
|
||||||
|
if (-not (Test-Path $wxs)) {
|
||||||
|
Write-Error "Fichier WXS introuvable : $wxs"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
Copy-Item $wxs -Destination "QElectroTech.wxs"
|
||||||
|
Write-Host "WXS prêt."
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# 7. Vérifier la structure de l'artifact
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- name: Check artifact structure
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
Write-Host "=== Contenu de artifact\files ==="
|
||||||
|
Get-ChildItem -Path "artifact\files" -Recurse -Depth 2 |
|
||||||
|
Select-Object FullName | Format-Table -AutoSize
|
||||||
|
|
||||||
|
$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)"
|
||||||
|
|
||||||
|
# Identifier le dossier bin/ contenant l'exe
|
||||||
|
$binDir = $exe.Directory.FullName
|
||||||
|
echo "BIN_DIR=$binDir" >> $env:GITHUB_ENV
|
||||||
|
|
||||||
|
# FilesDir = parent de bin/ (équivalent de nsis_root\files\)
|
||||||
|
$filesDir = Split-Path $binDir -Parent
|
||||||
|
echo "FILES_DIR=$filesDir" >> $env:GITHUB_ENV
|
||||||
|
Write-Host "FILES_DIR : $filesDir"
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# 8. Construire le MSI avec wix build
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
- name: Build MSI
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
$version = "${{ steps.version.outputs.VERSION_MSI }}"
|
||||||
|
$verDisplay = "${{ steps.version.outputs.VERSION_DISPLAY }}"
|
||||||
|
$filesDir = $env:FILES_DIR
|
||||||
|
$outputName = "QElectroTech-${verDisplay}_x86_64-win64.msi"
|
||||||
|
|
||||||
|
Write-Host "=== wix build ==="
|
||||||
|
Write-Host " Version : $version"
|
||||||
|
Write-Host " FilesDir : $filesDir"
|
||||||
|
Write-Host " Output : $outputName"
|
||||||
|
|
||||||
|
wix build QElectroTech.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. (Optionnel) Attacher le MSI à la release nightly
|
||||||
|
# Décommenter si tu veux le MSI dans les releases GitHub
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# - name: Upload MSI to nightly release
|
||||||
|
# uses: softprops/action-gh-release@v2
|
||||||
|
# if: github.ref == 'refs/heads/master'
|
||||||
|
# with:
|
||||||
|
# tag_name: nightly
|
||||||
|
# files: dist/*.msi
|
||||||
|
# env:
|
||||||
|
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# 11. 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 "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