Commit 65e0bc4f45
Unsigned
Layout: unified · split
.github/workflows/ci-cd.yml +125 −1
| @@ -180,6 +180,129 @@ jobs: | ||
| 180 | 180 | & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "Build\curd-windows-build.iss" |
| 181 | 181 | shell: pwsh |
| 182 | 182 | |
| 183 | - name: Build direct commit release notes | |
| 184 | run: | | |
| 185 | $ErrorActionPreference = 'Stop' | |
| 186 | ||
| 187 | $repo = "${{ github.repository }}" | |
| 188 | $token = "${{ secrets.ACTIONS_PAT }}" | |
| 189 | $headers = @{ | |
| 190 | Authorization = "Bearer $token" | |
| 191 | Accept = "application/vnd.github+json" | |
| 192 | "X-GitHub-Api-Version" = "2022-11-28" | |
| 193 | } | |
| 194 | ||
| 195 | $currentTag = "v$env:CURD_VERSION" | |
| 196 | $tags = @(git tag --sort=-version:refname "v*") | |
| 197 | $previousTag = $null | |
| 198 | foreach ($tag in $tags) { | |
| 199 | if ($tag -ne $currentTag) { | |
| 200 | $previousTag = $tag | |
| 201 | break | |
| 202 | } | |
| 203 | } | |
| 204 | ||
| 205 | if ($previousTag) { | |
| 206 | $range = "$previousTag..HEAD" | |
| 207 | } else { | |
| 208 | $rootCommit = (git rev-list --max-parents=0 HEAD | Select-Object -First 1) | |
| 209 | if ([string]::IsNullOrWhiteSpace($rootCommit)) { | |
| 210 | $range = "HEAD" | |
| 211 | } else { | |
| 212 | $range = "$rootCommit..HEAD" | |
| 213 | } | |
| 214 | } | |
| 215 | ||
| 216 | $rawCommits = @(git log --no-merges --pretty=format:'%H%x09%s%x09%an' $range) | |
| 217 | if ($rawCommits.Count -eq 1 -and [string]::IsNullOrWhiteSpace($rawCommits[0])) { | |
| 218 | $rawCommits = @() | |
| 219 | } | |
| 220 | ||
| 221 | $directCommitLines = @() | |
| 222 | $contributorSet = @{} | |
| 223 | ||
| 224 | foreach ($entry in $rawCommits) { | |
| 225 | $parts = $entry -split "`t", 3 | |
| 226 | if ($parts.Count -lt 3) { | |
| 227 | continue | |
| 228 | } | |
| 229 | ||
| 230 | $sha = $parts[0].Trim() | |
| 231 | $subject = $parts[1].Trim() | |
| 232 | $authorName = $parts[2].Trim() | |
| 233 | ||
| 234 | if ([string]::IsNullOrWhiteSpace($sha) -or [string]::IsNullOrWhiteSpace($subject)) { | |
| 235 | continue | |
| 236 | } | |
| 237 | ||
| 238 | if ($subject -match '^\s*release:') { | |
| 239 | continue | |
| 240 | } | |
| 241 | ||
| 242 | $pullsUri = "https://api.github.com/repos/$repo/commits/$sha/pulls" | |
| 243 | $pulls = @() | |
| 244 | try { | |
| 245 | $pulls = @(Invoke-RestMethod -Uri $pullsUri -Headers $headers -Method Get) | |
| 246 | } catch { | |
| 247 | $pulls = @() | |
| 248 | } | |
| 249 | ||
| 250 | # Skip commits that are already represented by pull requests in generated notes. | |
| 251 | if ($pulls.Count -gt 0) { | |
| 252 | continue | |
| 253 | } | |
| 254 | ||
| 255 | $commitUri = "https://api.github.com/repos/$repo/commits/$sha" | |
| 256 | $login = $null | |
| 257 | try { | |
| 258 | $commitData = Invoke-RestMethod -Uri $commitUri -Headers $headers -Method Get | |
| 259 | if ($null -ne $commitData.author -and $null -ne $commitData.author.login) { | |
| 260 | $login = $commitData.author.login | |
| 261 | } | |
| 262 | } catch { | |
| 263 | $login = $null | |
| 264 | } | |
| 265 | ||
| 266 | $shortSha = $sha.Substring(0, 7) | |
| 267 | if (-not [string]::IsNullOrWhiteSpace($login)) { | |
| 268 | $authorDisplay = "[@$login](https://github.com/$login)" | |
| 269 | } else { | |
| 270 | $authorDisplay = $authorName | |
| 271 | } | |
| 272 | ||
| 273 | $contributorSet[$authorDisplay] = $true | |
| 274 | $directCommitLines += "- $subject ([$shortSha](https://github.com/$repo/commit/$sha)) by $authorDisplay" | |
| 275 | } | |
| 276 | ||
| 277 | $notesPath = "Build/release-notes-extra.md" | |
| 278 | ||
| 279 | $body = @() | |
| 280 | $body += "## Direct Commits" | |
| 281 | if ($directCommitLines.Count -eq 0) { | |
| 282 | $body += "- No direct commits in this release range." | |
| 283 | } else { | |
| 284 | $body += $directCommitLines | |
| 285 | } | |
| 286 | ||
| 287 | $body += "" | |
| 288 | $body += "## Direct Commit Contributors" | |
| 289 | $contributors = @($contributorSet.Keys | Sort-Object) | |
| 290 | if ($contributors.Count -eq 0) { | |
| 291 | $body += "- None" | |
| 292 | } else { | |
| 293 | foreach ($contributor in $contributors) { | |
| 294 | $body += "- $contributor" | |
| 295 | } | |
| 296 | } | |
| 297 | ||
| 298 | if ($previousTag) { | |
| 299 | $body += "" | |
| 300 | $body += "_Range: $previousTag..HEAD_" | |
| 301 | } | |
| 302 | ||
| 303 | $body | Set-Content -Path $notesPath -Encoding utf8 | |
| 304 | shell: pwsh | |
| 305 | ||
| 183 | 306 | - name: Create Release |
| 184 | 307 | id: create_release |
| 185 | 308 | uses: softprops/action-gh-release@v1 |
| @@ -188,7 +311,8 @@ jobs: | ||
| 188 | 311 | name: "Curd v${{ env.CURD_VERSION }}" |
| 189 | 312 | draft: false |
| 190 | 313 | prerelease: false |
| 191 | generate_release_notes: true | |
| 314 | generate_release_notes: true | |
| 315 | body_path: Build/release-notes-extra.md | |
| 192 | 316 | files: | |
| 193 | 317 | releases/curd-${{ env.CURD_VERSION }}/linux/curd-linux-x86_64 |
| 194 | 318 | releases/curd-${{ env.CURD_VERSION }}/linux/curd-linux-arm64 |