|
3 | 3 | # separate terms of service, privacy policy, and support |
4 | 4 | # documentation. |
5 | 5 |
|
6 | | -name: .NET Desktop |
| 6 | +# This workflow will build, test, sign and package a WPF or Windows Forms desktop application |
| 7 | +# built on .NET Core. |
| 8 | +# To learn how to migrate your existing application to .NET Core, |
| 9 | +# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework |
| 10 | +# To configure this workflow: |
| 11 | +# |
| 12 | +# 1. Configure environment variables |
| 13 | +# GitHub sets default environment variables for every workflow run. |
| 14 | +# Replace the variables relative to your project in the "env" section below. |
| 15 | +# |
| 16 | +# 2. Signing |
| 17 | +# Generate a signing certificate in the Windows Application |
| 18 | +# Packaging Project or add an existing signing certificate to the project. |
| 19 | +# Next, use PowerShell to encode the .pfx file using Base64 encoding |
| 20 | +# by running the following Powershell script to generate the output string: |
| 21 | +# |
| 22 | +# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte |
| 23 | +# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt' |
| 24 | +# |
| 25 | +# Open the output file, SigningCertificate_Encoded.txt, and copy the |
| 26 | +# string inside. Then, add the string to the repo as a GitHub secret |
| 27 | +# and name it "Base64_Encoded_Pfx." |
| 28 | +# For more information on how to configure your signing certificate for |
| 29 | +# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing |
| 30 | +# |
| 31 | +# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key". |
| 32 | +# See "Build the Windows Application Packaging project" below to see how the secret is used. |
| 33 | +# |
| 34 | +# For more information on GitHub Actions, refer to https://github.com/features/actions |
| 35 | +# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications, |
| 36 | +# refer to https://github.com/microsoft/github-actions-for-desktop-apps |
| 37 | + |
| 38 | +name: .NET Core Desktop |
7 | 39 |
|
8 | 40 | on: |
9 | 41 | push: |
10 | 42 | branches: [ "master" ] |
| 43 | + pull_request: |
| 44 | + branches: [ "master" ] |
11 | 45 |
|
12 | 46 | jobs: |
| 47 | + |
13 | 48 | build: |
14 | | - runs-on: windows-2019 # For a list of available runner types, refer to |
| 49 | + |
| 50 | + strategy: |
| 51 | + matrix: |
| 52 | + configuration: [Debug, Release] |
| 53 | + |
| 54 | + runs-on: windows-latest # For a list of available runner types, refer to |
15 | 55 | # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on |
16 | 56 |
|
| 57 | + env: |
| 58 | + Solution_Name: your-solution-name # Replace with your solution name, i.e. MyWpfApp.sln. |
| 59 | + Test_Project_Path: your-test-project-path # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj. |
| 60 | + Wap_Project_Directory: your-wap-project-directory-name # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package. |
| 61 | + Wap_Project_Path: your-wap-project-path # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj. |
| 62 | + |
17 | 63 | steps: |
18 | 64 | - name: Checkout |
19 | 65 | uses: actions/checkout@v4 |
20 | 66 | with: |
21 | 67 | fetch-depth: 0 |
22 | 68 |
|
23 | | - - name: Setup MSBuild.exe |
24 | | - uses: microsoft/setup-msbuild@v1 |
25 | | - |
26 | | - - name: Restore Packages |
27 | | - run: nuget restore SatIPTV.sln |
| 69 | + # Install the .NET Core workload |
| 70 | + - name: Install .NET Core |
| 71 | + uses: actions/setup-dotnet@v4 |
| 72 | + with: |
| 73 | + dotnet-version: 8.0.x |
28 | 74 |
|
| 75 | + # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild |
29 | 76 | - name: Setup MSBuild.exe |
30 | | - uses: microsoft/setup-msbuild@v1 |
| 77 | + uses: microsoft/setup-msbuild@v2 |
| 78 | + |
| 79 | + # Execute all unit tests in the solution |
| 80 | + - name: Execute unit tests |
| 81 | + run: dotnet test |
31 | 82 |
|
32 | 83 | # Restore the application to populate the obj folder with RuntimeIdentifiers |
33 | 84 | - name: Restore the application |
34 | | - run: msbuild SatIPTV.sln /t:Restore /p:Configuration=Release |
| 85 | + run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration |
| 86 | + env: |
| 87 | + Configuration: ${{ matrix.configuration }} |
| 88 | + |
| 89 | + # Decode the base 64 encoded pfx and save the Signing_Certificate |
| 90 | + - name: Decode the pfx |
| 91 | + run: | |
| 92 | + $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") |
| 93 | + $certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx |
| 94 | + [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) |
| 95 | +
|
| 96 | + # Create the app package by building and packaging the Windows Application Packaging project |
| 97 | + - name: Create the app package |
| 98 | + run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} |
| 99 | + env: |
| 100 | + Appx_Bundle: Always |
| 101 | + Appx_Bundle_Platforms: x86|x64 |
| 102 | + Appx_Package_Build_Mode: StoreUpload |
| 103 | + Configuration: ${{ matrix.configuration }} |
| 104 | + |
| 105 | + # Remove the pfx |
| 106 | + - name: Remove the pfx |
| 107 | + run: Remove-Item -path $env:Wap_Project_Directory\GitHubActionsWorkflow.pfx |
| 108 | + |
| 109 | + # Upload the MSIX package: https://github.com/marketplace/actions/upload-a-build-artifact |
| 110 | + - name: Upload build artifacts |
| 111 | + uses: actions/upload-artifact@v3 |
| 112 | + with: |
| 113 | + name: MSIX Package |
| 114 | + path: ${{ env.Wap_Project_Directory }}\AppPackages |
0 commit comments