-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (85 loc) · 3.78 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# 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.UnitTests\Corathing.Organizer.UnitTests.csproj
Wpf_Project_Path: src\Apps\Corathing.Organizer\Corathing.Organizer.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 }}