-
Notifications
You must be signed in to change notification settings - Fork 0
229 lines (200 loc) · 11.6 KB
/
cd.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# This continuous delivery pipeline is meant to be triggered on release, anytime a user pushes code associated to a git tag,
# and will run against multiple configurations and production environments.
# This pipeline builds the Wpf project based upon the configuration matrix below. In order to
# create different channels of the application, the pipeline uses the Package.Identity.Name defined in the
# Package.appxmanifest in the Windows Application Packaging Project to uniquely identify the application,
# depending on which channel is being built.
# Once the MSIX is created for each channel configuration, the agent archives the AppPackages folder, then creates
# a Release with the specified git release tag. The archive is uploaded to the release as an asset for storage or distribution.
name: Wpf Continuous Delivery
# Trigger on any push with a git tag
# To create a git tag, run the following commands on the branch you wish to release:
# git tag 1.0.0.0
# git push origin --tags
on:
push:
tags:
- '*'
jobs:
build:
strategy:
# The following build matrix allows builds across multiple configurations (Debug and Release) and production environments such as
# development, production for sideload applications and production for the Microsoft store.
# For more information, see https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix
matrix:
channel: [Dev, DevExe, ProdExe, Prod_Sideload, Prod_Store]
targetPlatform: [x64]
include:
# includes the following variables for the matrix leg matching Dev
- channel: Dev
ChannelName: Dev
Configuration: Debug
DistributionUrl: https://github.com/dogzz9445/Corathing/Releases
MsixPackageId: Corathing.Organzier.Dev
MsixPublisherId: CN=Corathing
MsixPackageDisplayName: Corathing Organzier (Dev)
# includes the following variables for the matrix leg matching DevExe
- channel: DevExe
ChannelName: DevExe
Configuration: Debug
DistributionUrl: https://github.com/dogzz9445/Corathing/Releases
MsixPackageId: Corathing.Organzier.DevExe
MsixPublisherId: CN=Corathing
MsixPackageDisplayName: Corathing Organzier (DevExe)
# includes the following variables for the matrix leg matching ProdExe
- channel: ProdExe
ChannelName: ProdExe
Configuration: Release
DistributionUrl: https://github.com/dogzz9445/Corathing/Releases
MsixPackageId: Corathing.Organzier.ProdExe
MsixPublisherId: CN=Corathing
MsixPackageDisplayName: Corathing Organzier (ProdExe)
# includes the following variables for the matrix leg matching Prod_Sideload
- channel: Prod_Sideload
Configuration: Release
ChannelName: Prod_Sideload
DistributionUrl: https://github.com/dogzz9445/Corathing/Releases
MsixPackageId: Corathing.Organzier.ProdSideload
MsixPublisherId: CN=Corathing
MsixPackageDisplayName: Corathing Organzier (ProdSideload)
# includes the following variables for the matrix leg matching Prod_Store
- channel: Prod_Store
Configuration: Release
ChannelName: Prod_Store
DistributionUrl:
MsixPackageId: Corathing.Organzier.ProdStore
MsixPublisherId: CN=Corathing
MsixPackageDisplayName: Corathing Organzier (ProdStore)
runs-on: windows-latest
env:
App_Packages_Archive: AppPackages.zip
App_Packages_Directory: AppPackages
SigningCertificate: GitHubActionsPackageCorathing.pfx
Solution_Path: Corathing.sln
Wpf_Project_Directory: src\Apps\Corathing.Organizer.WPF
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 appxmanifest before build by setting the per-channel values set in the matrix such as
# the Package.Identity.Version or the Package.Identity.Name, which allows multiple channels to be built.
- 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.Package.Identity.Name = "${{ matrix.MsixPackageId }}"
$manifest.Package.Identity.Publisher = "${{ matrix.MsixPublisherId }}"
$manifest.Package.Properties.DisplayName = "${{ matrix.MsixPackageDisplayName }}"
$manifest.Package.Applications.Application.VisualElements.DisplayName = "${{ matrix.MsixPackageDisplayName }}"
$manifest.save(".\$env:Wap_Project_Directory\Package.appxmanifest")
# 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)
if: matrix.ChannelName != 'Prod_Store'
# 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: ${{ matrix.Configuration }}
RuntimeIdentifier: win-${{ matrix.targetplatform }}
# Build the Windows Application for DevExe and ProdExe
- name: Build the Wpf Application for ${{ matrix.ChannelName }}
run: msbuild $env:Wpf_Project_Path /p:Platform=$env:TargetPlatform /p:Configuration=$env:Configuration
if: matrix.ChannelName == 'DevExe' || matrix.ChannelName == 'ProdExe'
env:
Configuration: ${{ matrix.Configuration }}
TargetPlatform: ${{ matrix.targetplatform }}
# Build the Windows Application Packaging project for Dev and Prod_Sideload
- name: Build the Windows Application Packaging Project (wapproj) for ${{ matrix.ChannelName }}
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 }}
if: matrix.ChannelName == 'Dev' || matrix.ChannelName == 'Prod_Sideload'
env:
AppxBundle: Never
AppInstallerUri: ${{ matrix.DistributionUrl }}
BuildMode: SideloadOnly
Configuration: ${{ matrix.Configuration }}
GenerateAppInstallerFile: True
TargetPlatform: ${{ matrix.targetplatform }}
# Build the Windows Application Packaging project for Prod_Store
- name: Build the Windows Application Packaging Project (wapproj) for ${{ matrix.ChannelName }}
run: msbuild $env:Solution_Path /p:Platform=$env:TargetPlatform /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:BuildMode /p:AppxBundle=$env:AppxBundle /p:GenerateAppInstallerFile=$env:GenerateAppInstallerFile /p:AppxPackageSigningEnabled=$env:AppxPackageSigningEnabled
if: matrix.ChannelName == 'Prod_Store'
env:
AppxBundle: Never
AppxPackageSigningEnabled: False
BuildMode: StoreUpload
Configuration: ${{ matrix.Configuration }}
GenerateAppInstallerFile: False
TargetPlatform: ${{ matrix.targetplatform }}
# Remove the .pfx
- name: Remove the .pfx
run: Remove-Item -path $env:Wap_Project_Directory\$env:SigningCertificate
if: matrix.ChannelName != 'Prod_Store'
# Archive the exe
- name: Create archive exe
run: Compress-Archive -Path $env:Wpf_Project_Directory\bin\$env:Configuration\$env:TargetPlatform\* -DestinationPath $env:Wpf_Project_Directory\bin\$env:Configuration\$env:TargetPlatform\$matrix:ChannelName.zip
if: matrix.ChannelName == 'DevExe' || matrix.ChannelName == 'ProdExe'
# Archive the package
- name: Create archive package
run: Compress-Archive -Path $env:Wap_Project_Directory\$env:App_Packages_Directory\* -DestinationPath $env:Wap_Project_Directory\$env:App_Packages_Directory\$env:App_Packages_Archive
if: matrix.ChannelName == 'Dev' || matrix.ChannelName == 'Prod_Sideload' || matrix.ChannelName == 'Prod_Store'
# Create the release: https://github.com/actions/create-release
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref}}.${{matrix.ChannelName}}.${{ matrix.targetplatform }}
release_name: ${{ github.ref }}.${{ matrix.ChannelName }}.${{ matrix.targetplatform }}
draft: false
prerelease: false
# Upload release asset: https://github.com/actions/upload-release-asset
- name: Update release asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{ env.Wap_Project_Directory }}\${{ env.App_Packages_Directory }}\${{ env.App_Packages_Archive }}
asset_name: ${{ env.App_Packages_Archive }}
asset_content_type: application/zip
if: matrix.ChannelName == 'Dev' || matrix.ChannelName == 'Prod_Sideload' || matrix.ChannelName == 'Prod_Store'
# Upload the exe
- name: Update release asset exe
id: upload-release-asset-exe
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Configuration: ${{ matrix.Configuration }}
TargetPlatform: ${{ matrix.targetplatform }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{ env.Wpf_Project_Directory }}\bin\${{ env.Configuration }}\${{ env.TargetPlatform }}\${{ matrix.ChannelName }}.zip
asset_name: ${{ matrix.ChannelName }}.zip
asset_content_type: application/zip
if: matrix.ChannelName == 'DevExe' || matrix.ChannelName == 'ProdExe'