-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (173 loc) · 7.87 KB
/
Copy pathrelease.yml
File metadata and controls
186 lines (173 loc) · 7.87 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
name: release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: windows-latest
steps:
- name: Checkout (with full history + tags)
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Stamp version + publish (Portable + Setup)
shell: pwsh
run: |
$version = $env:GITHUB_REF_NAME.TrimStart('v')
Write-Host "Publishing version: $version"
$fileVersion = $version -replace '-.*$', ''
# Portable: today's single-file 150 MB exe. Built first because
# the existing Definition-of-Done check (publish\DiffViewer.exe
# must exist) targets this layout.
dotnet publish DiffViewer\DiffViewer.csproj `
-c Release `
-p:DiffViewerBuildMode=Portable `
-o publish `
-p:Version=$version `
-p:FileVersion=$fileVersion `
-p:InformationalVersion=$version
if (-not (Test-Path 'publish\DiffViewer.exe')) {
Write-Error 'publish\DiffViewer.exe not found after Portable publish'
exit 1
}
# Rename to a friendlier asset name; the upload step references
# DiffViewer-portable.exe so users see "what is this" cues from
# the filename alone.
New-Item -ItemType Directory -Path 'artifacts' -Force | Out-Null
Copy-Item -Path 'publish\DiffViewer.exe' -Destination 'artifacts\DiffViewer-portable.exe' -Force
# Setup: non-single-file folder layout consumed by vpk pack
# below. Built into a separate output dir so the two publishes
# don't fight over the same files.
dotnet publish DiffViewer\DiffViewer.csproj `
-c Release `
-p:DiffViewerBuildMode=Setup `
-o publish-setup `
-p:Version=$version `
-p:FileVersion=$fileVersion `
-p:InformationalVersion=$version
if (-not (Test-Path 'publish-setup\DiffViewer.exe')) {
Write-Error 'publish-setup\DiffViewer.exe not found after Setup publish'
exit 1
}
- name: Restore dotnet tools (vpk)
run: dotnet tool restore
- name: Download prior release packages (for delta)
# First release with Velopack support has no prior nupkgs to
# download; vpk download exits non-zero in that case (and any
# other transient failure). Tolerate that — vpk pack will then
# produce a full-only release, which is exactly the right
# outcome for the first Setup release.
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
run: |
New-Item -ItemType Directory -Path 'releases-dir' -Force | Out-Null
dotnet vpk download github `
--repoUrl https://github.com/${{ github.repository }} `
--token $env:GITHUB_TOKEN `
--outputDir releases-dir
- name: Pack Velopack release (vpk pack)
shell: pwsh
run: |
$version = $env:GITHUB_REF_NAME.TrimStart('v')
# --shortcuts StartMenuRoot (not the default Desktop+StartMenu)
# avoids the Phase 1 spike finding that Velopack 1.1.1's
# uninstall does not clean up the Desktop shortcut.
dotnet vpk pack `
--packId DiffViewer `
--packVersion $version `
--packDir publish-setup `
--mainExe DiffViewer.exe `
--outputDir releases-dir `
--shortcuts StartMenuRoot `
--packTitle DiffViewer `
--packAuthors "Geeven Singh"
# Sanity-check the expected artifacts are present. The delta
# nupkg only exists from the second release onward (no prior
# full to diff against on the first one), so its absence is
# not an error.
if (-not (Test-Path "releases-dir\DiffViewer-win-Setup.exe")) {
Write-Error 'DiffViewer-win-Setup.exe missing after vpk pack'
exit 1
}
if (-not (Test-Path "releases-dir\DiffViewer-$version-full.nupkg")) {
Write-Error "DiffViewer-$version-full.nupkg missing after vpk pack"
exit 1
}
# Copy / rename for the upload step. We want
# DiffViewer-Setup.exe (no win-* infix) as the user-facing
# download name.
Copy-Item -Path "releases-dir\DiffViewer-win-Setup.exe" -Destination 'artifacts\DiffViewer-Setup.exe' -Force
Copy-Item -Path "releases-dir\DiffViewer-$version-full.nupkg" -Destination "artifacts\DiffViewer-$version-full.nupkg" -Force
# The delta nupkg is optional (absent on first release).
$delta = Get-ChildItem -Path "releases-dir\DiffViewer-$version-delta.nupkg" -ErrorAction SilentlyContinue
if ($delta) {
Copy-Item -Path $delta.FullName -Destination "artifacts\DiffViewer-$version-delta.nupkg" -Force
}
# RELEASES + Velopack metadata files are required for the
# auto-updater to discover available packages on the
# GitHub release page.
Copy-Item -Path 'releases-dir\RELEASES' -Destination 'artifacts\RELEASES' -Force
if (Test-Path 'releases-dir\releases.win.json') {
Copy-Item -Path 'releases-dir\releases.win.json' -Destination 'artifacts\releases.win.json' -Force
}
if (Test-Path 'releases-dir\assets.win.json') {
Copy-Item -Path 'releases-dir\assets.win.json' -Destination 'artifacts\assets.win.json' -Force
}
- name: Extract CHANGELOG section
shell: pwsh
run: |
$version = $env:GITHUB_REF_NAME.TrimStart('v')
$changelog = 'CHANGELOG.md'
if (-not (Test-Path $changelog)) {
Write-Error "$changelog not found at repo root."
exit 1
}
$lines = Get-Content -LiteralPath $changelog
# Match the exact section header `## [<version>]` followed by EOL
# or ` -` (date). Anchor to start-of-line so we don't match e.g.
# `### Foo ## [0.2.0]` accidentally.
$headerPattern = '^## \[' + [regex]::Escape($version) + '\](\s|$)'
$start = -1
for ($i = 0; $i -lt $lines.Count; $i++) {
if ($lines[$i] -match $headerPattern) { $start = $i; break }
}
if ($start -lt 0) {
Write-Error "No '## [$version]' section in CHANGELOG.md. Add one before tagging."
exit 1
}
# Extract everything after the heading line up to the next `## [`
# (next release section) or EOF. Trim leading/trailing blank lines.
$end = $lines.Count
for ($j = $start + 1; $j -lt $lines.Count; $j++) {
if ($lines[$j] -match '^## \[') { $end = $j; break }
}
$section = ($lines[($start + 1)..($end - 1)] -join "`n").Trim()
if ([string]::IsNullOrWhiteSpace($section)) {
Write-Error "Section '## [$version]' in CHANGELOG.md is empty. Fill it in before tagging."
exit 1
}
Write-Host "Extracted $($section.Length) chars from '## [$version]'."
"RELEASE_BODY<<EOF`n$section`nEOF" | Out-File -Append -Encoding utf8 $env:GITHUB_ENV
- name: Publish GitHub Release
uses: softprops/action-gh-release@v3
with:
# Upload every asset from artifacts/ — Setup.exe + portable.exe
# are the user-facing downloads; the *.nupkg files + RELEASES +
# *.json files are what the in-app updater consumes silently.
files: artifacts/*
body: ${{ env.RELEASE_BODY }}
fail_on_unmatched_files: true