Update cd #79
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
# Copyright (c) Microsoft Corporation. | |
# Licensed under the MIT license. | |
# This continuous integration pipeline is triggered anytime a user pushes code to the repo. | |
# This pipeline builds the Wpf project, runs unit tests, then saves the MSIX build artifact. | |
name: Wpf Continuous Integration | |
# Trigger on every main branch push and pull request | |
on: | |
push: | |
branches: | |
- main | |
- 'maintenence/*' | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
strategy: | |
matrix: | |
targetplatform: [x64] | |
runs-on: windows-latest | |
env: | |
App_Packages_Directory: AppPackages | |
SigningCertificate: GitHubActionsPackageCorathing.pfx | |
Solution_Path: Corathing.sln | |
Test_Project_Path: src\Apps\Corathing.Organizer.WPF.UnitTests\Corathing.Organizer.WPF.UnitTests.csproj | |
Wpf_Project_Path: src\Apps\Corathing.Organizer.WPF\Corathing.Organizer.WPF.csproj | |
Wap_Project_Directory: src\Apps\Corathing.Package | |
Wap_Project_Name: Corathing.Package.wapproj | |
Actions_Allow_Unsecure_Commands: true # Allows AddPAth and SetEnv commands | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # avoid shallow clone so nbgv can do its work. | |
# Use Nerdbank.GitVersioning to set version variables: https://github.com/AArnott/nbgv | |
- name: Use Nerdbank.GitVersioning to set version variables | |
uses: dotnet/nbgv@master | |
id: nbgv | |
# Install the .NET Core workload | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
# Add MsBuild to the PATH: https://github.com/microsoft/setup-msbuild | |
- name: Setup MSBuild.exe | |
uses: microsoft/setup-msbuild@v2 | |
# Update the version before build | |
- name: Update manifest version | |
run: | | |
[xml]$manifest = get-content ".\$env:Wap_Project_Directory\Package.appxmanifest" | |
$manifest.Package.Identity.Version = "${{ steps.nbgv.outputs.SimpleVersion }}.0" | |
$manifest.save(".\$env:Wap_Project_Directory\Package.appxmanifest") | |
# Test | |
- name: Execute Unit Tests | |
run: dotnet test $env:Test_Project_Path | |
# Restore the application | |
- name: Restore the Wpf application to populate the obj folder | |
run: msbuild $env:Solution_Path /t:Restore /p:Configuration=$env:Configuration /p:RuntimeIdentifier=$env:RuntimeIdentifier | |
env: | |
Configuration: Debug | |
RuntimeIdentifier: win-${{ matrix.targetplatform }} | |
# Decode the Base64 encoded Pfx | |
- name: Decode the Pfx | |
run: | | |
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}") | |
$currentDirectory = Get-Location | |
$certificatePath = Join-Path -Path $currentDirectory -ChildPath $env:Wap_Project_Directory -AdditionalChildPath $env:SigningCertificate | |
[IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) | |
# Build the Windows Application Packaging project | |
- name: Build the Windows Application Packaging Project (wapproj) | |
run: msbuild $env:Solution_Path /p:Platform=$env:TargetPlatform /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:BuildMode /p:AppxBundle=$env:AppxBundle /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} | |
env: | |
AppxBundle: Never | |
BuildMode: SideloadOnly | |
Configuration: Debug | |
TargetPlatform: ${{ matrix.targetplatform }} | |
# Remove the .pfx | |
- name: Remove the .pfx | |
run: Remove-Item -path $env:Wap_Project_Directory\$env:SigningCertificate | |
# Upload the MSIX package: https://github.com/marketplace/actions/upload-artifact | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: MSIX Package | |
path: ${{ env.Wap_Project_Directory }}\${{ env.App_Packages_Directory }} |