Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,18 +263,40 @@ jobs:
"$env:RELEASE_ASSETS_DIR\Ceiling-$env:RELEASE_VERSION-portable.exe",
"$env:RELEASE_ASSETS_DIR\Ceiling-$env:RELEASE_VERSION-portable.exe.sha256"
)
$changelog = Get-Content CHANGELOG.md -Raw
$heading = "## [Ceiling] $($env:RELEASE_VERSION)"
$pattern = "(?ms)^" + [regex]::Escape($heading) + "[^\r\n]*\r?\n.*?(?=^## |\z)"
$section = [regex]::Match($changelog, $pattern)
if (-not $section.Success) {
throw "CHANGELOG.md has no section for $($env:RELEASE_VERSION); the release notes come from the changelog."
}
$notes = $section.Value.Trim()
$previousTag = (git describe --tags --abbrev=0 "$tag^" 2>$null)
if ($LASTEXITCODE -eq 0 -and $previousTag) {
$notes += "`n`n**Full Changelog**: https://github.com/$env:GITHUB_REPOSITORY/compare/$previousTag...$tag"
}
$notesPath = Join-Path $env:RUNNER_TEMP "release-notes.md"
Set-Content -Path $notesPath -Value $notes -Encoding utf8

$releaseJson = gh release view $tag --json isDraft --repo $env:GITHUB_REPOSITORY 2>$null
if ($LASTEXITCODE -eq 0) {
$release = $releaseJson | ConvertFrom-Json
if (-not $release.isDraft) {
throw "Refusing to replace assets on published release $tag."
}
gh release upload $tag @assets --clobber --repo $env:GITHUB_REPOSITORY
if ($LASTEXITCODE -ne 0) {
throw "Failed to upload assets to draft release $tag."
}
gh release edit $tag --notes-file $notesPath --title "Ceiling $env:RELEASE_VERSION" --repo $env:GITHUB_REPOSITORY
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if ($LASTEXITCODE -ne 0) {
throw "Failed to update draft release $tag."
}
} else {
gh release create $tag @assets `
--verify-tag `
--draft `
--generate-notes `
--notes-file $notesPath `
--title "Ceiling $env:RELEASE_VERSION" `
--repo $env:GITHUB_REPOSITORY
}
Expand Down