-
-
Notifications
You must be signed in to change notification settings - Fork 12
218 lines (185 loc) · 8.97 KB
/
publish-release.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
name: Release generation
on:
push:
tags:
- "v*.*.*"
jobs:
build:
runs-on: windows-latest
env:
Configuration: Release
Appx_Bundle: Always
Appx_Package_Build_Mode: StoreUpload
Solution_Name: ${{github.workspace}}\src\Gpt.Labs.sln
Project_Name: Gpt_Labs
x64_Packages_Folder_Path: ${{github.workspace}}\packages\x64
x86_Packages_Folder_Path: ${{github.workspace}}\packages\x86
arm64_Packages_Folder_Path: ${{github.workspace}}\packages\arm64
Source_Folder_Path: ${{github.workspace}}\packages\source
Boundle_Folder_Path: ${{github.workspace}}\packages\bundle
Project_Folder_Path: ${{github.workspace}}\src\Gpt.Labs
Pfx_Name: GptLabs_SideloadingKey.pfx
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.0.2
- name: Get application version
id: versionStep
run: |
$xml = [XML](Get-Content $env:Project_Folder_Path\Package.appxmanifest)
$version = $xml.Package.Identity.Version
echo "Version=$version" >> $env:GITHUB_OUTPUT
- name: Restore the application
run: |
msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
- name: Decode the pfx
id: decodePfxStep
run: |
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
$certificatePath = Join-Path -Path $env:Project_Folder_Path -ChildPath $env:Pfx_Name
[IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)
$secure_string_pwd = ConvertTo-SecureString "${{ secrets.Pfx_Key }}" -AsPlainText -Force
$thumbprint = (Import-PfxCertificate -FilePath "$certificatePath" -CertStoreLocation Cert:\CurrentUser\My -Password $secure_string_pwd).Thumbprint
echo "Thumbprint=$thumbprint" >> $env:GITHUB_OUTPUT
- name: Replace App Center Secret
id: replaceAppCenterSecret
run: |
(Get-Content $env:Project_Folder_Path\App.xaml.cs) | Foreach-Object {$_ -replace "{APP_CENTER_SECRET}", "${{ secrets.App_Center_Secret }}"} | Set-Content $env:Project_Folder_Path\App.xaml.cs
- name: Create the x64 app package
run: |
msbuild `
$env:Solution_Name `
/t:$env:Project_Name `
/p:Configuration=$env:Configuration `
/p:Platform=$env:Platform `
/p:AppxBundlePlatforms=$env:Platform `
/p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode `
/p:AppxBundle=$env:Appx_Bundle `
/p:AppxPackageSigningEnabled=true `
/p:PackageCertificateKeyFile=$env:Project_Folder_Path\$env:Pfx_Name `
/p:PackageCertificatePassword=${{ secrets.Pfx_Key }} `
/p:PackageCertificateThumbprint=${{steps.decodePfxStep.outputs.Thumbprint}} `
/p:GenerateAppxPackageOnBuild=true `
/p:AppxSymbolPackageEnabled=true `
/p:AppxPackageDir=$env:x64_Packages_Folder_Path\
env:
Platform: x64
- name: Create the x86 app package
run: |
msbuild `
$env:Solution_Name `
/t:$env:Project_Name `
/p:Configuration=$env:Configuration `
/p:Platform=$env:Platform `
/p:AppxBundlePlatforms=$env:Platform `
/p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode `
/p:AppxBundle=$env:Appx_Bundle `
/p:AppxPackageSigningEnabled=true `
/p:PackageCertificateKeyFile=$env:Project_Folder_Path\$env:Pfx_Name `
/p:PackageCertificatePassword=${{ secrets.Pfx_Key }} `
/p:PackageCertificateThumbprint=${{steps.decodePfxStep.outputs.Thumbprint}} `
/p:GenerateAppxPackageOnBuild=true `
/p:AppxSymbolPackageEnabled=true `
/p:AppxPackageDir=$env:x86_Packages_Folder_Path\
env:
Platform: x86
- name: Create the arm64 app package
run: |
msbuild `
$env:Solution_Name `
/t:$env:Project_Name `
/p:Configuration=$env:Configuration `
/p:Platform=$env:Platform `
/p:AppxBundlePlatforms=$env:Platform `
/p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode `
/p:AppxBundle=$env:Appx_Bundle `
/p:AppxPackageSigningEnabled=true `
/p:PackageCertificateKeyFile=$env:Project_Folder_Path\$env:Pfx_Name `
/p:PackageCertificatePassword=${{ secrets.Pfx_Key }} `
/p:PackageCertificateThumbprint=${{steps.decodePfxStep.outputs.Thumbprint}} `
/p:GenerateAppxPackageOnBuild=true `
/p:AppxSymbolPackageEnabled=true `
/p:AppxPackageDir=$env:arm64_Packages_Folder_Path\
env:
Platform: arm64
- name: Generate the msixbundle folder with all the msix files
run: |
New-Item -Path $env:Boundle_Folder_Path -ItemType Directory -Force
$x64MsixFiles = Get-ChildItem -Path $env:x64_Packages_Folder_Path\Gpt.Labs_${{steps.versionStep.outputs.Version}}_Test -Filter *.msix
$x86MsixFiles = Get-ChildItem -Path $env:x86_Packages_Folder_Path\Gpt.Labs_${{steps.versionStep.outputs.Version}}_Test -Filter *.msix
$arm64MsixFiles = Get-ChildItem -Path $env:arm64_Packages_Folder_Path\Gpt.Labs_${{steps.versionStep.outputs.Version}}_Test -Filter *.msix
$x64MsixFiles | ForEach-Object {
Copy-Item -Path $_ -Destination $env:Boundle_Folder_Path
}
$x86MsixFiles | ForEach-Object {
Copy-Item -Path $_ -Destination $env:Boundle_Folder_Path
}
$arm64MsixFiles | ForEach-Object {
Copy-Item -Path $_ -Destination $env:Boundle_Folder_Path
}
- name: MSIX Bundler
uses: LanceMcCarthy/Action-MsixBundler@v1.0.1
with:
msix-folder: ${{env.Boundle_Folder_Path}}
msixbundle-filepath: ${{env.Boundle_Folder_Path}}\Gpt.Labs_${{steps.versionStep.outputs.Version}}_x64_x86_arm64.msixbundle
msixbundle-version: ${{steps.versionStep.outputs.Version}}
sdk-version: 10.0.22621.0
architecture: x64
enable-bundle-signing: true
certificate-path: ${{env.Project_Folder_Path}}\${{env.Pfx_Name}}
certificate-private-key: ${{secrets.Pfx_Key}}
signing-hash-algorithm: SHA256
- name: Cleanup redundant and secret files
run: |
Remove-Item -path $env:Project_Folder_Path\$env:Pfx_Name
$msixFiles = Get-ChildItem -Path $env:Boundle_Folder_Path -Recurse -Exclude *.msixbundle
$msixFiles | ForEach-Object {
Remove-Item -Path $_
}
- name: Copy optional files
run: |
$optionalFiles = Get-ChildItem -Path $env:x64_Packages_Folder_Path\Gpt.Labs_${{steps.versionStep.outputs.Version}}_Test -Recurse -Include *.cer,*.ps1,*.msixsym
$optionalFiles | ForEach-Object {
Copy-Item -Path $_ -Destination $env:Boundle_Folder_Path
}
$dependenciesDirectory = Get-ChildItem -Path $env:x64_Packages_Folder_Path\Gpt.Labs_${{steps.versionStep.outputs.Version}}_Test -Directory -Recurse -Include Dependencies
$dependenciesDirectory | ForEach-Object {
Copy-Item -Recurse -Path $_ -Destination $env:Boundle_Folder_Path
}
$resourceDirectory = Get-ChildItem -Path $env:x64_Packages_Folder_Path\Gpt.Labs_${{steps.versionStep.outputs.Version}}_Test -Directory -Recurse -Include Add-AppDevPackage.resources
$resourceDirectory | ForEach-Object {
Copy-Item -Recurse -Path $_ -Destination $env:Boundle_Folder_Path
}
$x86symfiles = Get-ChildItem -Path $env:x86_Packages_Folder_Path -Recurse -Include *.msixsym
$x86symfiles | ForEach-Object {
Copy-Item -Path $_ -Destination $env:Boundle_Folder_Path
}
$arm64symfiles = Get-ChildItem -Path $env:arm64_Packages_Folder_Path -Recurse -Include *.msixsym
$arm64symfiles | ForEach-Object {
Copy-Item -Path $_ -Destination $env:Boundle_Folder_Path
}
$oldCertName = (Get-Item -Path "$env:Boundle_Folder_Path\*.cer").Name
$newCertName = $oldCertName.Replace("x64","x64_x86_arm64")
Rename-Item -Path "$env:Boundle_Folder_Path\$oldCertName" -NewName $newCertName
- name: Compress MSIX Bundler
run: |
New-Item -Path $env:Source_Folder_Path -ItemType Directory -Force
Compress-Archive -Path "$env:Boundle_Folder_Path\*" -DestinationPath "GPT.Labs_MSIXBUNDLE_v${{steps.versionStep.outputs.Version}}_x64_x86_arm64.zip"
- name: Release publish
uses: softprops/action-gh-release@v0.1.15
with:
name: ${{steps.versionStep.outputs.Version}}
generate_release_notes: true
draft: false
prerelease: false
files: |
GPT.Labs_MSIXBUNDLE_v${{steps.versionStep.outputs.Version}}_x64_x86_arm64.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}