-
Notifications
You must be signed in to change notification settings - Fork 2
393 lines (343 loc) · 12.8 KB
/
release-publish.yml
File metadata and controls
393 lines (343 loc) · 12.8 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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
name: Desktop Release
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
concurrency:
group: desktop-release-${{ github.ref_name }}
cancel-in-progress: false
jobs:
validate_release_ref:
name: Validate Release Ref
runs-on: ubuntu-latest
steps:
- name: Enforce Supported Release Branches
shell: bash
run: |
if [[ "${GITHUB_REF_NAME}" == "main" ]]; then
exit 0
fi
echo "Desktop releases may only run from main." >&2
exit 1
prepare_release:
name: Prepare Release
runs-on: ubuntu-latest
needs:
- validate_release_ref
outputs:
application_version: ${{ steps.resolve_version.outputs.application_version }}
previous_tag: ${{ steps.previous_tag.outputs.value }}
release_tag: ${{ steps.resolve_version.outputs.release_tag }}
release_version: ${{ steps.resolve_version.outputs.display_version }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install Dependencies
uses: "./.github/steps/install_dependencies"
- name: Fetch Tags
shell: bash
run: git fetch --tags --force
- name: Capture Previous Tag
id: previous_tag
shell: bash
run: |
previous_tag="$(git tag --list 'v*' --sort=-version:refname | head -n 1)"
echo "value=${previous_tag}" >> "$GITHUB_OUTPUT"
- name: Resolve Release Version
id: resolve_version
shell: bash
run: |
version_prefix="$(dotnet msbuild ./DotPilot/DotPilot.csproj -getProperty:ApplicationDisplayVersion | tail -n 1 | tr -d '\r')"
if [[ ! "${version_prefix}" =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "ApplicationDisplayVersion must be a two-segment numeric prefix. Found: '${version_prefix}'." >&2
exit 1
fi
display_version="${version_prefix}.${{ github.run_number }}"
{
echo "display_version=${display_version}"
echo "application_version=${{ github.run_number }}"
echo "release_tag=v${display_version}"
} >> "$GITHUB_OUTPUT"
publish_macos:
name: Publish macOS Release Asset
runs-on: macos-latest
timeout-minutes: 60
needs:
- prepare_release
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Install Dependencies
timeout-minutes: 60
uses: "./.github/steps/install_dependencies"
- name: Resolve macOS RID
id: macos_rid
shell: bash
run: |
architecture="$(uname -m)"
case "${architecture}" in
arm64)
rid="osx-arm64"
asset_suffix="macos-arm64"
;;
x86_64)
rid="osx-x64"
asset_suffix="macos-x64"
;;
*)
echo "Unsupported macOS runner architecture: ${architecture}" >&2
exit 1
;;
esac
echo "rid=${rid}" >> "$GITHUB_OUTPUT"
echo "asset_suffix=${asset_suffix}" >> "$GITHUB_OUTPUT"
- name: Publish macOS Disk Image
shell: bash
working-directory: ./DotPilot
run: |
dotnet publish DotPilot.csproj \
-c Release \
-f net10.0-desktop \
-r "${{ steps.macos_rid.outputs.rid }}" \
-warnaserror \
-m:1 \
-p:BuildInParallel=false \
-p:SelfContained=true \
-p:PackageFormat=dmg \
-p:CodesignKey=- \
-p:DiskImageSigningKey=- \
-p:ApplicationDisplayVersion=${{ needs.prepare_release.outputs.release_version }} \
-p:ApplicationVersion=${{ needs.prepare_release.outputs.application_version }}
- name: Stage macOS Release Asset
shell: bash
run: |
mkdir -p ./artifacts/releases
source_path="./DotPilot/bin/Release/net10.0-desktop/${{ steps.macos_rid.outputs.rid }}/publish/DotPilot.dmg"
target_path="./artifacts/releases/dotpilot-${{ needs.prepare_release.outputs.release_version }}-${{ steps.macos_rid.outputs.asset_suffix }}.dmg"
if [[ ! -f "${source_path}" ]]; then
echo "Expected macOS release asset was not produced: ${source_path}" >&2
exit 1
fi
cp "${source_path}" "${target_path}"
- name: Upload macOS Release Artifact
uses: actions/upload-artifact@v4
with:
name: dotpilot-release-macos
path: ./artifacts/releases/*.dmg
if-no-files-found: error
retention-days: 14
publish_windows:
name: Publish Windows Release Asset
runs-on: windows-latest
timeout-minutes: 60
needs:
- prepare_release
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Install Dependencies
timeout-minutes: 60
uses: "./.github/steps/install_dependencies"
- name: Publish Windows Single-File Executable
shell: pwsh
working-directory: .\DotPilot
run: >
dotnet publish DotPilot.csproj
-c Release
-f net10.0-desktop
-r win-x64
-warnaserror
-m:1
-p:BuildInParallel=false
-p:SelfContained=true
-p:PublishSingleFile=true
-p:IncludeNativeLibrariesForSelfExtract=true
-p:IncludeAllContentForSelfExtract=true
-p:ApplicationDisplayVersion=${{ needs.prepare_release.outputs.release_version }}
-p:ApplicationVersion=${{ needs.prepare_release.outputs.application_version }}
- name: Stage Windows Release Asset
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path .\artifacts\releases | Out-Null
$sourcePath = ".\DotPilot\bin\Release\net10.0-desktop\win-x64\publish\DotPilot.exe"
$targetPath = ".\artifacts\releases\dotpilot-${{ needs.prepare_release.outputs.release_version }}-windows-x64.exe"
if (-not (Test-Path $sourcePath)) {
throw "Expected Windows release asset was not produced: $sourcePath"
}
Copy-Item $sourcePath $targetPath -Force
- name: Upload Windows Release Artifact
uses: actions/upload-artifact@v4
with:
name: dotpilot-release-windows
path: ./artifacts/releases/*.exe
if-no-files-found: error
retention-days: 14
publish_linux:
name: Publish Linux Snap Release Asset
runs-on: ubuntu-24.04
timeout-minutes: 60
needs:
- prepare_release
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Install Dependencies
timeout-minutes: 60
uses: "./.github/steps/install_dependencies"
- name: Install Linux Snap Packaging Prerequisites
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y snapd
sudo systemctl start snapd.socket
sudo snap wait system seed.loaded
sudo snap install core24
sudo snap install multipass
sudo snap install lxd
sudo snap install snapcraft --classic
sudo lxd init --minimal
- name: Publish Linux Snap Package
shell: bash
working-directory: ./DotPilot
run: |
dotnet publish DotPilot.csproj \
-c Release \
-f net10.0-desktop \
-r linux-x64 \
-warnaserror \
-m:1 \
-p:BuildInParallel=false \
-p:SelfContained=true \
-p:PackageFormat=snap \
-p:UnoSnapcraftAdditionalParameters=--destructive-mode \
-p:ApplicationDisplayVersion=${{ needs.prepare_release.outputs.release_version }} \
-p:ApplicationVersion=${{ needs.prepare_release.outputs.application_version }}
- name: Stage Linux Release Asset
shell: bash
run: |
mkdir -p ./artifacts/releases
source_path="$(find ./DotPilot/bin/Release/net10.0-desktop/linux-x64/publish -maxdepth 1 -type f -name '*.snap' | sort | head -n 1)"
target_path="./artifacts/releases/dotpilot-${{ needs.prepare_release.outputs.release_version }}-linux-x64.snap"
if [[ -z "${source_path}" || ! -f "${source_path}" ]]; then
echo "Expected Linux snap release asset was not produced." >&2
exit 1
fi
cp "${source_path}" "${target_path}"
- name: Upload Linux Release Artifact
uses: actions/upload-artifact@v4
with:
name: dotpilot-release-linux
path: ./artifacts/releases/*.snap
if-no-files-found: error
retention-days: 14
create_release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs:
- prepare_release
- publish_macos
- publish_windows
- publish_linux
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Fetch Tags
shell: bash
run: git fetch --tags --force
- name: Download Release Artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts/release-assets
- name: Generate Feature Summary
shell: bash
env:
PREVIOUS_TAG: ${{ needs.prepare_release.outputs.previous_tag }}
RELEASE_TAG: ${{ needs.prepare_release.outputs.release_tag }}
REPOSITORY: ${{ github.repository }}
run: |
mkdir -p ./artifacts
commit_range="HEAD"
if [[ -n "${PREVIOUS_TAG}" ]]; then
commit_range="${PREVIOUS_TAG}..HEAD"
fi
git log --no-merges --pretty=format:%s "${commit_range}" |
awk 'NF && tolower($0) !~ /^chore\(release\):/ && !seen[$0]++' > ./artifacts/release-commits.txt
if [[ ! -s ./artifacts/release-commits.txt ]]; then
printf '%s\n' "Maintenance and release preparation changes." > ./artifacts/release-commits.txt
fi
: > ./artifacts/release-feature-docs.txt
if [[ -n "${PREVIOUS_TAG}" ]]; then
git diff --name-only "${PREVIOUS_TAG}..HEAD" -- 'docs/Features/*.md' |
awk '/^docs\/Features\// && !seen[$0]++' > ./artifacts/release-feature-docs.txt
elif [[ -d ./docs/Features ]]; then
find ./docs/Features -maxdepth 1 -type f -name '*.md' | sed 's#^\./##' | sort > ./artifacts/release-feature-docs.txt
fi
{
echo "## Feature Summary"
while IFS= read -r subject; do
if [[ -n "${subject}" ]]; then
echo "- ${subject}"
fi
done < ./artifacts/release-commits.txt
} > ./artifacts/release-summary.md
if [[ -s ./artifacts/release-feature-docs.txt ]]; then
{
echo
echo "## Feature Specs"
while IFS= read -r feature_doc; do
if [[ -z "${feature_doc}" ]]; then
continue
fi
title="$(sed -n 's/^# //p' "${feature_doc}" | head -n 1)"
if [[ -z "${title}" ]]; then
title="$(basename "${feature_doc}" .md)"
fi
printf -- '- [%s](https://github.com/%s/blob/%s/%s)\n' \
"${title}" \
"${REPOSITORY}" \
"${RELEASE_TAG}" \
"${feature_doc}"
done < ./artifacts/release-feature-docs.txt
} >> ./artifacts/release-summary.md
fi
- name: Publish GitHub Release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
PREVIOUS_TAG: ${{ needs.prepare_release.outputs.previous_tag }}
RELEASE_TAG: ${{ needs.prepare_release.outputs.release_tag }}
RELEASE_TARGET_SHA: ${{ github.sha }}
RELEASE_VERSION: ${{ needs.prepare_release.outputs.release_version }}
REPOSITORY: ${{ github.repository }}
run: |
mapfile -t release_assets < <(find ./artifacts/release-assets -type f | sort)
if [[ ${#release_assets[@]} -eq 0 ]]; then
echo "No release assets were downloaded." >&2
exit 1
fi
release_notes="$(cat ./artifacts/release-summary.md)"
release_command=(
gh release create "${RELEASE_TAG}"
"${release_assets[@]}"
--repo "${REPOSITORY}"
--target "${RELEASE_TARGET_SHA}"
--title "DotPilot ${RELEASE_VERSION}"
--generate-notes
--notes "${release_notes}"
)
if [[ -n "${PREVIOUS_TAG}" ]]; then
release_command+=(--notes-start-tag "${PREVIOUS_TAG}")
fi
"${release_command[@]}"