Package Installers as MSIX #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Package Installers as MSIX | |
on: | |
workflow_dispatch: | |
jobs: | |
package_installers: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
# This allows the action to push changes back to the repository | |
persist-credentials: false | |
- name: Set up Git User | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
shell: bash | |
- name: Install winget | |
uses: Cyberboss/install-winget@v1 | |
- name: Download MSIX Packaging Tool | |
run: | | |
$url = "https://download.microsoft.com/download/e/2/e/e2e923b2-7a3a-4730-969d-ab37001fbb5e/MSIXPackagingtoolv1.2024.405.0.msixbundle" # Replace with actual download link | |
$downloadPath = "C:\actions\workspace\MSIXPackagingTool.appxbundle" | |
Invoke-WebRequest -Uri $url -OutFile $downloadPath | |
shell: powershell | |
- name: Install MSIX Packaging Tool | |
run: | | |
$packagePath = "C:\actions\workspace\MSIXPackagingTool.appxbundle" | |
Add-AppxPackage -Path $packagePath | |
shell: powershell | |
# - name: Install MSIX Packaging Tool | |
# run: | | |
# winget install -e --id 9N5LW3JBCXKF -h --accept-package-agreements --accept-source-agreements | |
# shell: powershell | |
- name: Convert Installers to MSIX | |
run: | | |
# Set paths within the repository | |
$root = "${{ github.workspace }}\Installer" | |
$ConversionTemplate = Join-Path -Path $root -ChildPath "MsixTemplate.xml" | |
$MSIXSaveLocation = "${{ github.workspace }}\Converted" | |
# Create the save location if it doesn't exist | |
if (!(Test-Path -Path $MSIXSaveLocation)) { | |
New-Item -ItemType Directory -Path $MSIXSaveLocation | Out-Null | |
} | |
# Define valid installer extensions | |
$validExtensions = @(".msi", ".exe", ".appx") | |
Get-ChildItem -Path $root -Recurse | Where-Object { $validExtensions -contains $_.Extension.ToLower() } | ForEach-Object { | |
$InstallerPath = $_.FullName | |
$FileName = $_.BaseName | |
$XML_Path = Join-Path -Path $root -ChildPath "${FileName}_ConversionTemplate.xml" | |
$PackagePath = Join-Path -Path $MSIXSaveLocation -ChildPath "${FileName}.msix" | |
# Load the conversion template XML | |
[xml]$XmlDocument = Get-Content $ConversionTemplate | |
# Set installer-specific paths | |
$XmlDocument.MSIXPackagingToolTemplate.Installer.Path = $InstallerPath | |
# Set installer arguments based on file extension | |
switch ($_.Extension.ToLower()) { | |
".msi" { | |
$XmlDocument.MSIXPackagingToolTemplate.Installer.Arguments = "/qb" | |
} | |
".exe" { | |
# Set default silent install switch for executables (update as needed for specific apps) | |
$XmlDocument.MSIXPackagingToolTemplate.Installer.Arguments = "/S" | |
} | |
default { | |
$XmlDocument.MSIXPackagingToolTemplate.Installer.Arguments = "" | |
} | |
} | |
# Set the installation location and package path | |
$XmlDocument.MSIXPackagingToolTemplate.Installer.InstallLocation = "C:\Program Files (x86)\" | |
$XmlDocument.MSIXPackagingToolTemplate.SaveLocation.PackagePath = $PackagePath | |
# Configure package metadata | |
$XmlDocument.MSIXPackagingToolTemplate.PackageInformation.PublisherName = "CN=DWA, O=DWA, C=NL" | |
$XmlDocument.MSIXPackagingToolTemplate.PackageInformation.PublisherDisplayName = $FileName | |
$XmlDocument.MSIXPackagingToolTemplate.PackageInformation.PackageName = $FileName | |
$XmlDocument.MSIXPackagingToolTemplate.PackageInformation.PackageDisplayName = $FileName | |
$XmlDocument.MSIXPackagingToolTemplate.PackageInformation.Applications.Application.ExecutableName = $FileName + ".exe" | |
$XmlDocument.MSIXPackagingToolTemplate.PackageInformation.Applications.Application.DisplayName = $FileName | |
$XmlDocument.MSIXPackagingToolTemplate.PackageInformation.Applications.Application.Description = $FileName | |
$XmlDocument.MSIXPackagingToolTemplate.PackageInformation.Applications.Application.ID = $FileName + "1" | |
# Save the modified XML template | |
$XmlDocument.Save($XML_Path) | |
# Run MSIX Packaging Tool to create the package | |
MsixPackagingTool.exe create-package --template $XML_Path | |
} | |
shell: powershell | |
- name: Commit and Push MSIX Files to Repository | |
run: | | |
git add Converted/ | |
git commit -m "Add MSIX packages" | |
git push origin HEAD:${{ github.ref_name }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: bash |