Fix GitHub Actions workflows for UWP MSIX builds #3
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
| # This workflow builds and packages the UWP application as MSIX | ||
|
Check failure on line 1 in .github/workflows/dotnet-desktop.yml
|
||
| # For signing with a certificate, add Base64_Encoded_Pfx and Pfx_Key secrets to the repository | ||
| name: Build UWP MSIX | ||
| on: | ||
| push: | ||
| branches: [ "master" ] | ||
| pull_request: | ||
| branches: [ "master" ] | ||
| jobs: | ||
| build: | ||
| strategy: | ||
| matrix: | ||
| configuration: [Release] | ||
| platform: [x64] | ||
| runs-on: windows-latest | ||
| env: | ||
| Solution_Name: eComBox.sln | ||
| Project_Path: eComBox.csproj | ||
| AppxPackageDir: AppPackages\ | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Setup MSBuild | ||
| uses: microsoft/setup-msbuild@v2 | ||
| - name: Restore NuGet packages | ||
| run: nuget restore $env:Solution_Name | ||
| - name: Generate self-signed certificate (if secrets not available) | ||
| if: ${{ !secrets.Base64_Encoded_Pfx }} | ||
| run: | | ||
| New-SelfSignedCertificate -Type Custom -Subject "CN=eComBox Test Certificate" -KeyUsage DigitalSignature -FriendlyName "eComBox Test Cert" -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}") | ||
| $thumbprint = (Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object {$_.Subject -match "eComBox Test Certificate"} | Select-Object -First 1).Thumbprint | ||
| Write-Host "Certificate thumbprint: $thumbprint" | ||
| - name: Decode the pfx (if secret available) | ||
| if: ${{ secrets.Base64_Encoded_Pfx }} | ||
| run: | | ||
| $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") | ||
| $certificatePath = "GitHubActionsWorkflow.pfx" | ||
| [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) | ||
| - name: Build MSIX package (with certificate) | ||
| if: ${{ secrets.Base64_Encoded_Pfx }} | ||
| run: msbuild $env:Solution_Name /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }} /p:UapAppxPackageBuildMode=SideloadOnly /p:AppxBundle=Never /p:AppxPackageDir=$env:AppxPackageDir /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} /p:AppxPackageSigningEnabled=true | ||
| - name: Build MSIX package (without signing) | ||
| if: ${{ !secrets.Base64_Encoded_Pfx }} | ||
| run: msbuild $env:Solution_Name /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }} /p:UapAppxPackageBuildMode=SideloadOnly /p:AppxBundle=Never /p:AppxPackageDir=$env:AppxPackageDir /p:AppxPackageSigningEnabled=false | ||
| - name: Remove the pfx | ||
| if: ${{ secrets.Base64_Encoded_Pfx }} | ||
| run: Remove-Item -path GitHubActionsWorkflow.pfx -ErrorAction SilentlyContinue | ||
| - name: Upload MSIX package | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: MSIX-Package-${{ matrix.platform }}-${{ matrix.configuration }} | ||
| path: ${{ env.AppxPackageDir }}**/*.msix | ||