Change file names #133
This file contains hidden or 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: Build (WinUI 3) | |
| on: | |
| push: | |
| branches: [ "reset-winui3" ] | |
| pull_request: | |
| branches: [ "reset-winui3" ] | |
| workflow_call: | |
| inputs: | |
| release: | |
| required: true | |
| type: boolean | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| strategy: | |
| matrix: | |
| channel: [AppInstaller, Store] | |
| include: | |
| - channel: AppInstaller | |
| publisher: | |
| "CN=Đặng Bình Minh, O=Đặng Bình Minh, L=Hà Nội, C=VN" | |
| pkgName: | |
| "MicaForEveryone.MicaForEveryone2" | |
| - channel: Store | |
| publisher: | |
| "CN=95B8F56A-76FA-4743-83B0-5312C49D625D" | |
| pkgName: | |
| "DongleInsovaki.MicaForEveryone" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v5 | |
| - name: Change package identity | |
| run: | | |
| $manifestPath = "MicaForEveryone.App\Package.appxmanifest" | |
| $manifest = [xml](Get-Content $manifestPath) | |
| $manifest.Package.Identity.Publisher = "${{ matrix.publisher }}" | |
| $manifest.Package.Identity.Name = "${{ matrix.pkgName }}" | |
| $manifest.Save($manifestPath) | |
| - name: Login to Azure | |
| uses: azure/login@v3 | |
| if: ${{ inputs.release }} | |
| with: | |
| client-id: ${{ secrets.TS_CLIENT_ID }} | |
| tenant-id: ${{ secrets.TS_TENANT_ID }} | |
| subscription-id: ${{ secrets.TS_SUBSCRIPTION_ID }} | |
| - name: Create Trusted Signing configuration | |
| if: ${{ inputs.release }} | |
| run: | | |
| $config = @{ | |
| Endpoint = "${{ secrets.TS_ENDPOINT }}" | |
| CodeSigningAccountName = "${{ secrets.TS_ACCOUNT }}" | |
| CertificateProfileName = "${{ secrets.TS_CERT }}" | |
| } | |
| $json = $config | ConvertTo-Json | |
| $json | Out-File -FilePath "${{ github.workspace }}\trusted-signing.json" | |
| - name: Set App Center connection string | |
| if: ${{ inputs.release }} | |
| run: | | |
| $xmlPath = "${{ github.workspace}}\MicaForEveryone.App\appsettings.resw" | |
| [xml]$xml = Get-Content -Path $xmlPath | |
| $xml.root.data | Where-Object { $_.name -eq "AppCenterConnectionString" } | ForEach-Object { | |
| $_.value = "${{ secrets.AC_STRING }}" | |
| } | |
| $xml.Save($xmlPath) | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build MicaForEveryone.App\MicaForEveryone.App.csproj /p:Platform=x64 -c Release /p:GenerateAppxPackageOnBuild=true /p:UapAppxPackageBuildMode=${{ matrix.channel == 'Store' && 'CI' || 'SideloadOnly' }} /p:TrustedSigningEnabled=${{ inputs.release && 'true' || 'false' }} /p:TrustedSigningMetadataPath="${{ github.workspace }}\trusted-signing.json" --no-restore | |
| - name: Copy artifacts | |
| run: | | |
| $isStore = "${{ matrix.channel }}" -eq "Store" | |
| $extensions = if ($isStore) { (".msixupload") } else { (".msixbundle", ".appxsym", ".appinstaller") } | |
| $outputDir = "${{ github.workspace }}\output" | |
| $appPackagesDir = Get-ChildItem -Path . -Directory -Recurse | | |
| Where-Object { $_.Name -eq "AppPackages" } | | |
| Select-Object -First 1 | |
| New-Item -ItemType Directory -Path $outputDir -Force | Out-Null | |
| Get-ChildItem -Path $appPackagesDir -File -Recurse | | |
| Where-Object { $_.Extension -in $extensions -and $_.FullName -notmatch '\\Dependencies\\' } | | |
| ForEach-Object { | |
| Copy-Item -Path $_ -Destination $outputDir | |
| } | |
| if (-not $isStore) { | |
| $dependenciesDir = Get-ChildItem -Path $appPackagesDir -Directory -Recurse | | |
| Where-Object { $_.Name -eq "Dependencies" } | | |
| Select-Object -First 1 | |
| $dependencyOutputDir = Join-Path $outputDir "Dependencies" | |
| New-Item -ItemType Directory -Path $dependencyOutputDir -Force | Out-Null | |
| foreach ($arch in @("arm64", "x64", "x86")) { | |
| $archDirectories = Get-ChildItem -Path $dependenciesDir -Directory -Recurse | | |
| Where-Object { $_.Name -ieq $arch } | |
| foreach ($archDirectory in $archDirectories) { | |
| Get-ChildItem -Path $archDirectory -File -Filter "*.msix" | ForEach-Object { | |
| $destinationName = "{0}.{1}{2}" -f $_.BaseName, $arch, $_.Extension | |
| $destinationPath = Join-Path $dependencyOutputDir $destinationName | |
| Copy-Item -Path $_ -Destination $destinationPath -Force | |
| } | |
| } | |
| } | |
| } | |
| - name: Generate AppInstaller | |
| if: ${{ matrix.channel == 'AppInstaller' }} | |
| run: | | |
| $outputDir = "${{ github.workspace }}\output" | |
| $appInstallerPath = Get-ChildItem -Path $outputDir -Filter "*.appinstaller" -File | Select-Object -First 1 | |
| $msixbundlePath = Get-ChildItem -Path $outputDir -Filter "*.msixbundle" -File | Select-Object -First 1 | |
| if ($null -eq $appInstallerPath) { | |
| throw "AppInstaller file not found." | |
| } | |
| if ($null -eq $msixbundlePath) { | |
| throw "MSIX bundle file not found." | |
| } | |
| $releaseBaseUrl = "https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}" | |
| $msixbundleFileName = $msixbundlePath.Name | |
| $targetAppInstallerFileName = "MicaForEveryone.appinstaller" | |
| $targetAppInstallerPath = Join-Path $outputDir $targetAppInstallerFileName | |
| [xml]$appInstallerXml = Get-Content -LiteralPath $appInstallerPath.FullName | |
| $namespaceManager = New-Object System.Xml.XmlNamespaceManager($appInstallerXml.NameTable) | |
| $namespaceManager.AddNamespace("ai", $appInstallerXml.DocumentElement.NamespaceURI) | |
| $appInstallerXml.DocumentElement.SetAttribute("Uri", "https://micaforeveryone.github.io/MicaForEveryone.appinstaller") | |
| $mainBundleNode = $appInstallerXml.SelectSingleNode("//ai:MainBundle", $namespaceManager) | |
| if ($null -eq $mainBundleNode) { | |
| throw "MainBundle node not found in AppInstaller file." | |
| } | |
| $mainBundleNode.SetAttribute("Uri", "$releaseBaseUrl/$msixbundleFileName") | |
| $packageNodes = $appInstallerXml.SelectNodes("//ai:Dependencies/ai:Package", $namespaceManager) | |
| foreach ($packageNode in $packageNodes) { | |
| $packageName = $packageNode.GetAttribute("Name") | |
| $processorArchitecture = $packageNode.GetAttribute("ProcessorArchitecture") | |
| if ([string]::IsNullOrWhiteSpace($packageName) -or [string]::IsNullOrWhiteSpace($processorArchitecture)) { | |
| throw "Dependencies Package node is missing Name or ProcessorArchitecture attributes." | |
| } | |
| $packageFileName = "$packageName.$processorArchitecture.msix" | |
| $packageNode.SetAttribute("Uri", "$releaseBaseUrl/$packageFileName") | |
| } | |
| $updateSettingsNode = $appInstallerXml.SelectSingleNode("//ai:UpdateSettings", $namespaceManager) | |
| if ($null -eq $updateSettingsNode) { | |
| $updateSettingsNode = $appInstallerXml.CreateElement("UpdateSettings", $appInstallerXml.DocumentElement.NamespaceURI) | |
| [void]$appInstallerXml.DocumentElement.AppendChild($updateSettingsNode) | |
| } | |
| $automaticBackgroundTaskNode = $updateSettingsNode.SelectSingleNode("ai:AutomaticBackgroundTask", $namespaceManager) | |
| if ($null -eq $automaticBackgroundTaskNode) { | |
| $automaticBackgroundTaskNode = $appInstallerXml.CreateElement("AutomaticBackgroundTask", $appInstallerXml.DocumentElement.NamespaceURI) | |
| [void]$updateSettingsNode.AppendChild($automaticBackgroundTaskNode) | |
| } | |
| $appInstallerXml.Save($appInstallerPath.FullName) | |
| if ($appInstallerPath.FullName -ine $targetAppInstallerPath) { | |
| Move-Item -LiteralPath $appInstallerPath.FullName -Destination $targetAppInstallerPath -Force | |
| } | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ matrix.channel == 'Store' && 'StorePackage' || 'AppInstallerPackage' }} | |
| path: ${{ github.workspace }}\output\ | |
| archive: ${{ matrix.channel != 'Store' }} |