Repository navigation
347 lines (299 loc) · 12.5 KB
/
Copy pathrelease.yml
File metadata and controls
347 lines (299 loc) · 12.5 KB
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Release version (for example 5.0.0 or v5.0.0)"
required: true
prerelease:
description: "Mark the GitHub release as a prerelease"
required: false
default: false
type: boolean
permissions:
contents: write
jobs:
# ── WPF channel (v5.x and earlier) ─────────────────────────────────────
# Skips v6.* tags — those are built by the release-winui job below.
release:
if: >-
${{
(github.event_name == 'workflow_dispatch'
&& !startsWith(inputs.version, '6.')
&& !startsWith(inputs.version, 'v6.'))
|| (github.event_name != 'workflow_dispatch'
&& !startsWith(github.ref_name, 'v6.'))
}}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve release metadata
id: meta
shell: pwsh
run: |
[xml]$project = Get-Content 'OpenNotes.csproj'
$projectVersion = $project.Project.PropertyGroup.Version | Select-Object -First 1
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
$inputVersion = "${{ inputs.version }}".Trim()
if ([string]::IsNullOrWhiteSpace($inputVersion)) {
throw "workflow_dispatch requires a version input."
}
$version = $inputVersion.TrimStart('v')
$tag = "v$version"
$prerelease = if ("${{ inputs.prerelease }}" -eq "true") { "true" } else { "false" }
}
else {
$tag = "${{ github.ref_name }}"
$version = $tag.TrimStart('v')
$prerelease = "false"
}
$assemblyVersion = if ($version -match '^\d+\.\d+\.\d+$') {
"$version.0"
}
elseif ($version -match '^\d+\.\d+\.\d+\.\d+$') {
$version
}
else {
throw "Version '$version' must look like x.y.z or x.y.z.w."
}
$portableName = "OpenNotes-Portable-win-x64-$version.zip"
$installerName = "OpenNotes-Setup-$version.exe"
"version=$version" >> $env:GITHUB_OUTPUT
"tag=$tag" >> $env:GITHUB_OUTPUT
"assembly_version=$assemblyVersion" >> $env:GITHUB_OUTPUT
"portable_name=$portableName" >> $env:GITHUB_OUTPUT
"installer_name=$installerName" >> $env:GITHUB_OUTPUT
"prerelease=$prerelease" >> $env:GITHUB_OUTPUT
"project_version=$projectVersion" >> $env:GITHUB_OUTPUT
- name: Create release tag for manual runs
if: github.event_name == 'workflow_dispatch'
shell: pwsh
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git rev-parse --verify --quiet "refs/tags/${{ steps.meta.outputs.tag }}" *>$null
if ($LASTEXITCODE -eq 0) {
throw "Tag ${{ steps.meta.outputs.tag }} already exists."
}
git tag "${{ steps.meta.outputs.tag }}"
git push origin "${{ steps.meta.outputs.tag }}"
- name: Setup .NET 8
uses: actions/setup-dotnet@v5
with:
dotnet-version: "8.0.x"
- name: Install Inno Setup
shell: pwsh
run: choco install innosetup --no-progress -y
- name: Restore
run: dotnet restore .\OpenNotes.csproj
- name: Publish app
shell: pwsh
run: >
dotnet publish .\OpenNotes.csproj
-c Release
-r win-x64
--self-contained true
-o publish
-p:Version=${{ steps.meta.outputs.version }}
-p:InformationalVersion=${{ steps.meta.outputs.version }}
-p:AssemblyVersion=${{ steps.meta.outputs.assembly_version }}
-p:FileVersion=${{ steps.meta.outputs.assembly_version }}
- name: Build installer
shell: pwsh
run: >
& "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe" .\installer.iss
/DMyAppVersion=${{ steps.meta.outputs.version }}
/DMyAppOutputBaseFilename=OpenNotes-Setup-${{ steps.meta.outputs.version }}
- name: Package portable build
shell: pwsh
run: Compress-Archive -Path .\publish\* -DestinationPath ".\${{ steps.meta.outputs.portable_name }}" -Force
- name: Upload installer artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.meta.outputs.installer_name }}
path: .\installer_output\${{ steps.meta.outputs.installer_name }}
- name: Upload portable artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.meta.outputs.portable_name }}
path: .\${{ steps.meta.outputs.portable_name }}
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.meta.outputs.tag }}
name: OpenNotes ${{ steps.meta.outputs.version }}
prerelease: ${{ steps.meta.outputs.prerelease }}
generate_release_notes: true
files: |
.\installer_output\${{ steps.meta.outputs.installer_name }}
.\${{ steps.meta.outputs.portable_name }}
- name: Summarize downloads
shell: pwsh
run: |
@"
## Release outputs
- Installer artifact: ``${{ steps.meta.outputs.installer_name }}``
- Portable artifact: ``${{ steps.meta.outputs.portable_name }}``
- Release tag: ``${{ steps.meta.outputs.tag }}``
"@ >> $env:GITHUB_STEP_SUMMARY
# ── WinUI channel (v6.* tags / 6.x manual dispatch) ────────────────────
# Builds OpenNotes.WinUI: unpackaged (WindowsPackageType=None), Windows App
# SDK self-contained, x64 — a single folder publish that installer.iss and
# the portable zip package verbatim. Asset names stay identical to the WPF
# channel (OpenNotes-Setup-{v}.exe / OpenNotes-Portable-win-x64-{v}.zip);
# the installer keeps the same AppId/AppName so a V6 setup upgrades a 5.x
# install in place and reuses the %LOCALAPPDATA%\Caelum data directory.
release-winui:
if: >-
${{
(github.event_name == 'push'
&& startsWith(github.ref_name, 'v6.'))
|| (github.event_name == 'workflow_dispatch'
&& (startsWith(inputs.version, '6.') || startsWith(inputs.version, 'v6.')))
}}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve release metadata
id: meta
shell: pwsh
run: |
[xml]$project = Get-Content 'OpenNotes.WinUI\OpenNotes.WinUI.csproj'
$projectVersion = $project.Project.PropertyGroup.Version | Select-Object -First 1
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
$inputVersion = "${{ inputs.version }}".Trim()
if ([string]::IsNullOrWhiteSpace($inputVersion)) {
throw "workflow_dispatch requires a version input."
}
$version = $inputVersion.TrimStart('v')
$tag = "v$version"
$prerelease = if ("${{ inputs.prerelease }}" -eq "true") { "true" } else { "false" }
}
else {
$tag = "${{ github.ref_name }}"
$version = $tag.TrimStart('v')
$prerelease = "false"
}
$assemblyVersion = if ($version -match '^\d+\.\d+\.\d+$') {
"$version.0"
}
elseif ($version -match '^\d+\.\d+\.\d+\.\d+$') {
$version
}
else {
throw "Version '$version' must look like x.y.z or x.y.z.w."
}
if (-not $version.StartsWith('6.')) {
throw "release-winui only handles v6.* tags; got '$version'."
}
$portableName = "OpenNotes-Portable-win-x64-$version.zip"
$installerName = "OpenNotes-Setup-$version.exe"
"version=$version" >> $env:GITHUB_OUTPUT
"tag=$tag" >> $env:GITHUB_OUTPUT
"assembly_version=$assemblyVersion" >> $env:GITHUB_OUTPUT
"portable_name=$portableName" >> $env:GITHUB_OUTPUT
"installer_name=$installerName" >> $env:GITHUB_OUTPUT
"prerelease=$prerelease" >> $env:GITHUB_OUTPUT
"project_version=$projectVersion" >> $env:GITHUB_OUTPUT
- name: Create release tag for manual runs
if: github.event_name == 'workflow_dispatch'
shell: pwsh
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git rev-parse --verify --quiet "refs/tags/${{ steps.meta.outputs.tag }}" *>$null
if ($LASTEXITCODE -eq 0) {
throw "Tag ${{ steps.meta.outputs.tag }} already exists."
}
git tag "${{ steps.meta.outputs.tag }}"
git push origin "${{ steps.meta.outputs.tag }}"
- name: Setup .NET 8
uses: actions/setup-dotnet@v5
with:
dotnet-version: "8.0.x"
- name: Install Inno Setup
shell: pwsh
run: choco install innosetup --no-progress -y
- name: Restore
run: dotnet restore .\OpenNotes.WinUI\OpenNotes.WinUI.csproj
- name: Publish app (unpackaged, WASDK self-contained)
shell: pwsh
run: >
dotnet publish .\OpenNotes.WinUI\OpenNotes.WinUI.csproj
-c Release
-r win-x64
--self-contained true
-o publish-winui
-p:Version=${{ steps.meta.outputs.version }}
-p:InformationalVersion=${{ steps.meta.outputs.version }}
-p:AssemblyVersion=${{ steps.meta.outputs.assembly_version }}
-p:FileVersion=${{ steps.meta.outputs.assembly_version }}
- name: Verify compiled-XAML payload
shell: pwsh
run: |
# 'dotnet publish' drops the compiled XAML (.xbf) and app .pri for
# unpackaged WinUI apps; without them the exe crashes at startup
# with 0xC000027B. The CopyCompiledXamlToPublish target in the
# csproj restores them — fail here before a broken payload ships.
$required = @(
'publish-winui\OpenNotes.WinUI.pri',
'publish-winui\App.xbf',
'publish-winui\MainWindow.xbf',
'publish-winui\Pages\EditorPage.xbf',
'publish-winui\Pages\HomePage.xbf',
'publish-winui\Controls\PdfPageControl.xbf'
)
$missing = $required | Where-Object { -not (Test-Path $_) }
if ($missing) {
throw "Publish output is missing compiled-XAML artifacts: $($missing -join ', ')"
}
- name: Build installer
shell: pwsh
run: >
& "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe" .\installer.iss
/DMyAppVersion=${{ steps.meta.outputs.version }}
/DMyAppOutputBaseFilename=OpenNotes-Setup-${{ steps.meta.outputs.version }}
/DMyAppSourceDir=publish-winui
/DMyAppExeName=OpenNotes.WinUI.exe
/DMyAppWinUIPayload
- name: Package portable build
shell: pwsh
run: Compress-Archive -Path .\publish-winui\* -DestinationPath ".\${{ steps.meta.outputs.portable_name }}" -Force
- name: Upload installer artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.meta.outputs.installer_name }}
path: .\installer_output\${{ steps.meta.outputs.installer_name }}
- name: Upload portable artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.meta.outputs.portable_name }}
path: .\${{ steps.meta.outputs.portable_name }}
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.meta.outputs.tag }}
name: OpenNotes ${{ steps.meta.outputs.version }}
prerelease: ${{ steps.meta.outputs.prerelease }}
generate_release_notes: true
files: |
.\installer_output\${{ steps.meta.outputs.installer_name }}
.\${{ steps.meta.outputs.portable_name }}
- name: Summarize downloads
shell: pwsh
run: |
@"
## Release outputs
- Installer artifact: ``${{ steps.meta.outputs.installer_name }}``
- Portable artifact: ``${{ steps.meta.outputs.portable_name }}``
- Release tag: ``${{ steps.meta.outputs.tag }}``
"@ >> $env:GITHUB_STEP_SUMMARY