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
33 changes: 24 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
ref: ${{ steps.resolve.outputs.target_ref }}
fetch-depth: 0

- name: Extract release notes from CHANGELOG
- name: Compose release body from CHANGELOG
env:
VERSION: ${{ steps.resolve.outputs.version }}
TAG: ${{ steps.resolve.outputs.tag }}
Expand All @@ -77,13 +77,20 @@ jobs:
echo "::error::CHANGELOG.md must have a dated section '## ${VERSION} (YYYY-MM-DD)' before releasing."
exit 1
fi
awk -v ver="$VERSION_RE" '
$0 ~ "^## " ver " \\(" { found=1; next }
found && /^## [0-9]+\.[0-9]+\.[0-9]+ \(/ { exit }
found { print }
' CHANGELOG.md > /tmp/release-notes.md
if [ ! -s /tmp/release-notes.md ]; then
echo "::error::Empty release notes for ${TAG}. CHANGELOG.md must have a dated section for ${VERSION}."
{
echo "## \`ulc\` CLI ${TAG}"
echo ""
echo "Download a single-file binary for your platform below. See \`CHANGELOG.md\`"
echo "at the tag for what landed in this release."
echo ""
awk -v ver="$VERSION_RE" '
$0 ~ "^## " ver " \\(" { found=1; next }
found && /^## [0-9]+\.[0-9]+\.[0-9]+ \(/ { exit }
found { print }
' CHANGELOG.md
} > /tmp/release-body.md
if [ "$(wc -l < /tmp/release-body.md)" -lt 7 ]; then
echo "::error::Composed release body for ${TAG} is suspiciously short — CHANGELOG section may be empty."
exit 1
fi
Comment on lines +92 to 95
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 wc -l threshold may block valid single-entry releases

The header contributes exactly 5 lines, so the check requires awk to emit at least 2 lines of CHANGELOG content. A section with a single bullet (e.g. - Patch typo.) produces only 6 lines total and would fail this guard even though the extraction worked correctly. Lowering the threshold to 6 (i.e., "header + at least 1 CHANGELOG line") keeps the safety net while allowing minimal-but-valid sections.

Suggested change
if [ "$(wc -l < /tmp/release-body.md)" -lt 7 ]; then
echo "::error::Composed release body for ${TAG} is suspiciously short — CHANGELOG section may be empty."
exit 1
fi
if [ "$(wc -l < /tmp/release-body.md)" -lt 6 ]; then
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/release.yml
Line: 92-95

Comment:
**`wc -l` threshold may block valid single-entry releases**

The header contributes exactly 5 lines, so the check requires awk to emit at least 2 lines of CHANGELOG content. A section with a single bullet (e.g. `- Patch typo.`) produces only 6 lines total and would fail this guard even though the extraction worked correctly. Lowering the threshold to `6` (i.e., "header + at least 1 CHANGELOG line") keeps the safety net while allowing minimal-but-valid sections.

```suggestion
          if [ "$(wc -l < /tmp/release-body.md)" -lt 6 ]; then
```

How can I resolve this? If you propose a fix, please make it concise.


Expand Down Expand Up @@ -111,7 +118,15 @@ jobs:
with:
distribution: goreleaser
version: '~> v2'
args: release --clean --release-notes /tmp/release-notes.md
args: release --clean
workdir: tools/validator
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set GitHub Release body to composed content
env:
TAG: ${{ steps.resolve.outputs.tag }}
REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release edit "$TAG" --repo "$REPO" --notes-file /tmp/release-body.md
Loading