This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
136 lines (112 loc) · 5.09 KB
/
dotnet-build.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: .NET Build
on:
push:
pull_request:
workflow_dispatch:
jobs:
build-unpackaged:
name: Unpackaged Build
strategy:
matrix:
configuration: [Debug, Release]
platform: [x86, x64, arm64]
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Create $SHORT_SHA environment variable
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $env:GITHUB_ENV
- name: Set up .NET 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ matrix.platform }}-${{ hashFiles('**/*.csproj') }}
restore-keys: nuget-${{ runner.os }}-${{ matrix.platform }}-
- name: Cache build results
uses: actions/cache@v4
with:
path: |
./bin
./obj
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.configuration }}-${{ matrix.platform }}-${{ github.sha }}
restore-keys: ${{ github.job }}-${{ runner.os }}-${{ matrix.configuration }}-${{matrix.platform }}-
- name: Restore app dependencies
run: dotnet restore -p Configuration=${{ matrix.configuration }} -p Platform=${{ matrix.platform }} -v normal
- name: Build the app
run: dotnet build -p Configuration=${{ matrix.configuration }} -p Platform=${{ matrix.platform }} -v normal
- name: Publish the built app
run: dotnet publish -p Configuration=${{ matrix.configuration }} -p Platform=${{ matrix.platform }} -v normal
- name: Upload build results
uses: actions/upload-artifact@v3
with:
name: Miiverse-PC Unpackaged Build - ${{ matrix.configuration }} ${{ matrix.platform }} (${{ env.SHORT_SHA }})
path: ./bin/publish/
build-packaged:
# See https://docs.microsoft.com/en-us/windows/apps/package-and-deploy/ci-for-winui3 for example
name: Packaged Build
strategy:
matrix:
configuration: [Debug, Release]
platform: [x86, x64, arm64]
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Create $SHORT_SHA environment variable
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $env:GITHUB_ENV
- name: Set up .NET 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Set up MSBuild
uses: microsoft/setup-msbuild@v1
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ matrix.platform }}-${{ hashFiles('**/*.csproj') }}
restore-keys: nuget-${{ runner.os }}-${{ matrix.platform }}-
- name: Cache build results
uses: actions/cache@v4
with:
path: |
./bin
./obj
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.configuration }}-${{ matrix.platform }}-${{ github.sha }}
restore-keys: ${{ github.job }}-${{ runner.os }}-${{ matrix.configuration }}-${{ matrix.platform }}-
- name: Decode and store MSIX signing key
run: |
if ( -not ("${{ secrets.MSIX_SIGNING_KEY_BASE64 }}" -and "${{ secrets.MSIX_SIGNING_KEY_PASSWORD }}") )
{
echo "Skipping signing because the necessary secrets do not exist."
exit 0
}
$key_bytes = [System.Convert]::FromBase64String("${{ secrets.MSIX_SIGNING_KEY_BASE64 }}")
[IO.File]::WriteAllBytes("GitHubActions-Key.pfx", $key_bytes)
$password = ConvertTo-SecureString -String ${{ secrets.MSIX_SIGNING_KEY_PASSWORD }} -AsPlainText -Force
Import-PfxCertificate -FilePath GitHubActions-Key.pfx -CertStoreLocation "Cert:\CurrentUser\My" -Password $password
echo "THUMBPRINT=$((Get-PfxData -FilePath GitHubActions-Key.pfx -Password $password).EndEntityCertificates.Thumbprint)" >> $env:GITHUB_ENV
Remove-Item GitHubActions-Key.pfx
- name: Restore app dependencies
run: msbuild /t:Restore /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }}
- name: Build the app and generate a signed MSIX package
if: env.THUMBPRINT != ''
run:
msbuild /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }}
/p:PackageCertificateThumbprint=${{ env.THUMBPRINT }}
/p:AppxPackageDir="./Packages/" /p:GenerateAppxPackageOnBuild=true
- name: Build the app and generate an unsigned MSIX package
if: env.THUMBPRINT == ''
run:
msbuild /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }}
/p:AppxPackageSigningEnabled=false
/p:AppxPackageDir="./Packages/" /p:GenerateAppxPackageOnBuild=true
- name: Upload the MSIX package
uses: actions/upload-artifact@v3
with:
name: Miiverse-PC Package - ${{ matrix.configuration }} ${{ matrix.platform }} (${{ env.SHORT_SHA }})
path: ./Packages/