name: Build & Release MSI on: push: tags: - 'v*' jobs: build-msi: runs-on: windows-latest permissions: contents: write steps: - name: Checkout uses: actions/checkout@v4 - name: Extract version (strip leading v) id: ver shell: pwsh run: | $tag = "${{ github.ref_name }}" $ver = $tag.TrimStart('v') # WiX requires 4-part version (Major.Minor.Patch.Build) if ($ver -notmatch '^\d+\.\d+\.\d+\.\d+$') { $ver = "$ver.0" } echo "VERSION=$ver" >> $env:GITHUB_OUTPUT echo "TAG=$tag" >> $env:GITHUB_OUTPUT - name: Prepare staging directory shell: pwsh run: | $stage = "${{ runner.temp }}\stage" New-Item -ItemType Directory -Force $stage | Out-Null # Copy everything except Repo-/CI-/Dev-/macOS-only Dateien. Get-ChildItem -Path . -Exclude '.git','.github','installer','start-macos.command','tests','.gitattributes' | Copy-Item -Destination $stage -Recurse -Force - name: Install WiX Toolset v4 shell: pwsh run: | dotnet tool install --global wix --version "4.0.6" wix extension add "WixToolset.UI.wixext/4.0.6" --global - name: Generate WiX file fragment shell: pwsh run: | $stage = "${{ runner.temp }}\stage" $harvestWxs = "${{ runner.temp }}\AppFiles.wxs" $ns = "http://wixtoolset.org/schemas/v4/wxs" $doc = [System.Xml.XmlDocument]::new() $doc.AppendChild($doc.CreateXmlDeclaration("1.0","UTF-8",$null)) | Out-Null $wix = $doc.CreateElement("Wix", $ns); $doc.AppendChild($wix) | Out-Null $frag = $doc.CreateElement("Fragment", $ns); $wix.AppendChild($frag) | Out-Null $cg = $doc.CreateElement("ComponentGroup", $ns) $cg.SetAttribute("Id","AppFiles"); $cg.SetAttribute("Directory","INSTALLFOLDER") $frag.AppendChild($cg) | Out-Null $idx = 0 Get-ChildItem -Path $stage -Recurse -File | ForEach-Object { $rel = $_.FullName.Substring($stage.Length + 1) $relDir = [System.IO.Path]::GetDirectoryName($rel) $comp = $doc.CreateElement("Component", $ns) $comp.SetAttribute("Id", "Comp_$idx") $comp.SetAttribute("Guid", ("{$([System.Guid]::NewGuid().ToString().ToUpper())}")) if ($relDir) { $comp.SetAttribute("Subdirectory", $relDir) } $cg.AppendChild($comp) | Out-Null $f = $doc.CreateElement("File", $ns) $f.SetAttribute("Id", "File_$idx") $f.SetAttribute("Source", "`$(var.SourceDir)\$rel") $f.SetAttribute("KeyPath", "yes") $comp.AppendChild($f) | Out-Null $idx++ } $doc.Save($harvestWxs) Write-Host "Fragment: $harvestWxs ($idx files)" - name: Build MSI shell: pwsh run: | $stage = "${{ runner.temp }}\stage" $harvestWxs = "${{ runner.temp }}\AppFiles.wxs" $installerDir = "${{ github.workspace }}\installer" $msiName = "IntuneManager-${{ steps.ver.outputs.TAG }}.msi" wix build installer\Intune-Manager.wxs $harvestWxs ` -ext WixToolset.UI.wixext ` -d Version=${{ steps.ver.outputs.VERSION }} ` -d SourceDir=$stage ` -d InstallerDir=$installerDir ` -o $msiName echo "MSI_NAME=$msiName" >> $env:GITHUB_OUTPUT id: build - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: name: "Intune Manager ${{ steps.ver.outputs.TAG }}" body: | ## Intune Manager ${{ steps.ver.outputs.TAG }} ### Installation 1. `IntuneManager-${{ steps.ver.outputs.TAG }}.msi` herunterladen 2. Doppelklick → Installer folgen 3. Intune Manager über das Startmenü starten ### Voraussetzungen - Windows 10/11 - PowerShell 5.1 oder 7+ - `Microsoft.Graph.Authentication` Modul (wird beim ersten Start automatisch angeboten) files: "IntuneManager-${{ steps.ver.outputs.TAG }}.msi" generate_release_notes: false - name: Mirror MSI to Gitea release shell: pwsh env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_BASE: https://git.wende.it/api/v1 GITEA_OWNER: marco GITEA_REPO: Intune-Manager TAG: ${{ steps.ver.outputs.TAG }} MSI_NAME: ${{ steps.build.outputs.MSI_NAME }} COMMIT_SHA: ${{ github.sha }} run: | if ([string]::IsNullOrWhiteSpace($env:GITEA_TOKEN)) { Write-Host "::notice::GITEA_TOKEN nicht gesetzt — Gitea-Upload uebersprungen." exit 0 } $headers = @{ Authorization = "token $env:GITEA_TOKEN" } $repoUrl = "$($env:GITEA_BASE)/repos/$($env:GITEA_OWNER)/$($env:GITEA_REPO)" # Release per Tag suchen; sonst anlegen (Tag wird bei Bedarf am Commit erzeugt). $rel = $null try { $rel = Invoke-RestMethod -Headers $headers -Uri "$repoUrl/releases/tags/$($env:TAG)" -Method GET } catch { $rel = $null } if (-not $rel) { $body = @{ tag_name = $env:TAG target_commitish = $env:COMMIT_SHA name = "Intune Manager $($env:TAG)" body = "Automatisch aus der GitHub-CI gespiegelt." } | ConvertTo-Json $rel = Invoke-RestMethod -Headers $headers -Uri "$repoUrl/releases" -Method POST -ContentType 'application/json' -Body $body } $relId = $rel.id # Vorhandenes Asset gleichen Namens entfernen (idempotent bei Re-Runs). try { $assets = Invoke-RestMethod -Headers $headers -Uri "$repoUrl/releases/$relId/assets" -Method GET foreach ($a in @($assets)) { if ($a.name -eq $env:MSI_NAME) { Invoke-RestMethod -Headers $headers -Uri "$repoUrl/releases/$relId/assets/$($a.id)" -Method DELETE | Out-Null } } } catch {} # MSI als Attachment hochladen (multipart, Feldname 'attachment'). $assetUri = "$repoUrl/releases/$relId/assets?name=$([uri]::EscapeDataString($env:MSI_NAME))" Invoke-RestMethod -Headers $headers -Uri $assetUri -Method POST -Form @{ attachment = Get-Item -LiteralPath $env:MSI_NAME } | Out-Null Write-Host "MSI '$($env:MSI_NAME)' -> Gitea-Release '$($env:TAG)' hochgeladen."