Repository navigation
190 lines (173 loc) · 6.8 KB
/
Copy pathrelease.yml
File metadata and controls
190 lines (173 loc) · 6.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
name: Release
on:
push:
tags:
- 'release_*'
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
name: Build ${{ matrix.rid }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
rid: win-x64
- os: windows-latest
rid: win-arm64
- os: ubuntu-latest
rid: linux-x64
- os: ubuntu-latest
rid: linux-arm64
- os: macos-latest
rid: osx-arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Resolve version from tag
id: version
shell: pwsh
run: |
$tag = '${{ github.ref_name }}'
$version = $tag -replace '^release_', ''
try {
$null = [System.Version]$version
} catch {
throw "Tag '$tag' does not contain a valid version after the 'release_' prefix."
}
"version=$version" >> $env:GITHUB_OUTPUT
"tag=$tag" >> $env:GITHUB_OUTPUT
Write-Host "Building $tag ($version) for ${{ matrix.rid }}"
- name: Publish framework-dependent single file
run: >
dotnet publish FindRomCover/FindRomCover.csproj --configuration Release
--runtime ${{ matrix.rid }} --self-contained false
-p:PublishSingleFile=true
-p:IncludeNativeLibrariesForSelfExtract=true
-p:Version=${{ steps.version.outputs.version }}
-p:AssemblyVersion=${{ steps.version.outputs.version }}
-p:FileVersion=${{ steps.version.outputs.version }}
- name: Stage bundle contents
shell: pwsh
run: |
$publishDir = "FindRomCover/bin/Release/net10.0/${{ matrix.rid }}/publish"
if (-not (Test-Path -LiteralPath $publishDir)) {
throw "Publish folder not found: $publishDir"
}
$stageDir = "bundle-stage/${{ matrix.rid }}"
if (Test-Path -LiteralPath $stageDir) { Remove-Item -LiteralPath $stageDir -Recurse -Force }
New-Item -ItemType Directory -Path $stageDir -Force | Out-Null
Copy-Item -Path (Join-Path $publishDir '*') -Destination $stageDir -Recurse -Force
Copy-Item -LiteralPath 'LICENSE.txt' -Destination $stageDir -Force
Copy-Item -LiteralPath 'README.md' -Destination $stageDir -Force
Copy-Item -LiteralPath 'WhatsNew.md' -Destination $stageDir -Force
Get-ChildItem -Path $stageDir -Recurse -Include '*.pdb' -Force | Remove-Item -Force
Get-ChildItem -LiteralPath $stageDir -Force |
Format-Table Name, Length -AutoSize |
Out-String -Width 200 |
Write-Host
- name: Create bundle archive
shell: pwsh
run: |
$tag = '${{ steps.version.outputs.tag }}'
$zipName = "${tag}_${{ matrix.rid }}.zip"
$stageDir = "bundle-stage/${{ matrix.rid }}"
if (Test-Path -LiteralPath $zipName) { Remove-Item -LiteralPath $zipName -Force }
Compress-Archive -Path (Join-Path $stageDir '*') -DestinationPath $zipName
Get-Item -LiteralPath $zipName |
Format-Table Name, Length -AutoSize |
Out-String -Width 200 |
Write-Host
- name: Upload bundle artifact
uses: actions/upload-artifact@v4
with:
name: bundle-${{ matrix.rid }}
path: ${{ steps.version.outputs.tag }}_${{ matrix.rid }}.zip
if-no-files-found: error
release:
name: Create GitHub release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Download bundle artifacts
uses: actions/download-artifact@v4
with:
pattern: bundle-*
merge-multiple: true
path: assets
- name: Write release notes
shell: pwsh
run: |
$tag = '${{ github.ref_name }}'
$version = $tag -replace '^release_', ''
# Put the version's own "What's New" section into the release body instead of
# merely linking to WhatsNew.md. Fall back to a changelog link only when the
# section for the tagged version cannot be found.
$notes = $null
$lines = @(Get-Content -LiteralPath 'WhatsNew.md' -Encoding UTF8)
$start = -1
for ($i = 0; $i -lt $lines.Count; $i++) {
if ($lines[$i] -match ('^#\s+FindRomCover\s+' + [regex]::Escape($version) + '(\s|$)')) {
$start = $i
break
}
}
if ($start -ge 0) {
$end = $lines.Count
for ($i = $start + 1; $i -lt $lines.Count; $i++) {
if ($lines[$i] -match '^#\s+FindRomCover\s') {
$end = $i
break
}
}
$section = @($lines[$start..($end - 1)])
while ($section.Count -gt 0 -and ($section[-1] -eq '---' -or [string]::IsNullOrWhiteSpace($section[-1]))) {
$section = if ($section.Count -gt 1) { @($section[0..($section.Count - 2)]) } else { @() }
}
if ($section.Count -gt 0) { $notes = $section -join [Environment]::NewLine }
}
if ([string]::IsNullOrWhiteSpace($notes)) {
Write-Host "No 'What's New' section found for $version in WhatsNew.md; falling back to a changelog link."
$notes = @(
"# FindRomCover $version — What's New",
'',
"See [WhatsNew.md](https://github.com/${{ github.repository }}/blob/$tag/WhatsNew.md) for the full changelog.",
'',
'## Download',
'',
"- ``${tag}_win-x64.zip`` — Windows x64",
"- ``${tag}_win-arm64.zip`` — Windows ARM64",
"- ``${tag}_linux-x64.zip`` — Linux x64",
"- ``${tag}_linux-arm64.zip`` — Linux ARM64",
"- ``${tag}_osx-arm64.zip`` — macOS Apple Silicon"
) -join [Environment]::NewLine
}
else {
Write-Host "Release notes embedded from the What's New section for $version."
}
Set-Content -LiteralPath 'NOTES.md' -Value $notes -Encoding UTF8NoBOM
Get-ChildItem -LiteralPath 'assets' -Force |
Format-Table Name, Length -AutoSize |
Out-String -Width 200 |
Write-Host
- name: Create release and upload assets
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create '${{ github.ref_name }}' \
--title '${{ github.ref_name }}' \
--notes-file NOTES.md \
assets/*.zip