split create tag and update changelog workflows to fix race condition#262
split create tag and update changelog workflows to fix race condition#262
Conversation
📝 WalkthroughWalkthroughMoves changelog generation out of Changes
Sequence Diagram(s)sequenceDiagram
participant GH as GitHub (release event)
participant Runner as Actions Runner
participant API as GitHub API / gh
participant Repo as Git repository
rect rgba(200,230,255,0.5)
GH->>Runner: release.published event
end
Runner->>Repo: checkout (full history)
Runner->>API: list releases (paginated)
API-->>Runner: releases + bodies
Runner->>Runner: format entries, adjust headings, update CHANGELOG.md
Runner->>Repo: create branch chore/update-changelog-${tag}, commit changes
Runner->>API: check for existing PR for branch
alt PR exists
API-->>Runner: PR found → stop
else no PR
Runner->>API: create PR targeting main
API-->>Runner: PR created
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| --base main \ | ||
| --head "$BRANCH_NAME" | ||
| fi | ||
| # Changelog PR is created by the update-changelog.yml workflow |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/update-changelog.yml:
- Around line 35-45: The paginated gh api output may produce multiple JSON
arrays causing the downstream jq -r '.[]' to fail; change the pipeline so you
aggregate all pages before extracting fields (remove the per-page --jq and
instead pipe the raw gh api --paginate output into jq -s 'add' and then map to
{tagName,publishedAt}): run gh api --paginate repos/${{ github.repository
}}/releases?per_page=100 | jq -s 'add | map({tagName: .tag_name, publishedAt:
.published_at}) | .[] | "\(.tagName) \(.publishedAt)"' | while read -r tag
published_at; do ... (keep the existing loop body that calls gh release view
"$tag" and sed transformation and appends to CHANGELOG.md).
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/update-changelog.yml:
- Around line 35-38: The jq pipeline that builds the changelog currently
includes draft releases; update the jq expression used after the gh api call
(the pipeline using jq -s -r 'add | map({tagName: .tag_name, publishedAt:
.published_at}) | .[] | "\(.tagName) \(.publishedAt)"') to filter out draft
releases by inserting a select(.draft == false) (and also select(.prerelease ==
false) if prereleases must be excluded) before mapping, so only non-draft (and
optionally non-prerelease) releases are emitted to the while read loop.
| # Append all releases using JSON for reliable parsing (paginate to include all) | ||
| gh api --paginate repos/${{ github.repository }}/releases?per_page=100 \ | ||
| | jq -s -r 'add | map({tagName: .tag_name, publishedAt: .published_at}) | .[] | "\(.tagName) \(.publishedAt)"' \ | ||
| | while read -r tag published_at; do |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
GitHub REST API List releases GET /repos/{owner}/{repo}/releases draft prerelease fields
💡 Result:
GET /repos/{owner}/{repo}/releases returns an array of release objects, and each release object includes these boolean fields:
draft:trueif the release is a draft (unpublished), elsefalse. [1]prerelease:trueif the release is marked as a prerelease, elsefalse. [1]
Visibility note: only users with push access will have draft releases included in the list response; others only see published releases. [2]
Sources:
[1] GitHub REST API “List releases” example response schema (shows draft and prerelease). (docs.github.com)
[2] GitHub REST API “List releases” notes on draft visibility. (docs.github.com)
Citations:
- 1: https://docs.github.com/enterprise-cloud%40latest/rest/releases/releases
- 2: https://docs.github.com/enterprise-cloud%40latest/rest/releases/releases
Exclude draft releases from the changelog.
The releases API includes draft releases (for users with push access), which would surface unpublished notes in CHANGELOG.md. Filter them out in the jq pipeline using select(.draft == false) to avoid leaking draft content. If prereleases should also be excluded, add a prerelease == false predicate as well.
🔧 Proposed fix
- gh api --paginate repos/${{ github.repository }}/releases?per_page=100 \
- | jq -s -r 'add | map({tagName: .tag_name, publishedAt: .published_at}) | .[] | "\(.tagName) \(.publishedAt)"' \
+ gh api --paginate repos/${{ github.repository }}/releases?per_page=100 \
+ | jq -s -r 'add
+ | map(select(.draft == false) | {tagName: .tag_name, publishedAt: .published_at})
+ | .[] | "\(.tagName) \(.publishedAt)"' \🤖 Prompt for AI Agents
In @.github/workflows/update-changelog.yml around lines 35 - 38, The jq pipeline
that builds the changelog currently includes draft releases; update the jq
expression used after the gh api call (the pipeline using jq -s -r 'add |
map({tagName: .tag_name, publishedAt: .published_at}) | .[] | "\(.tagName)
\(.publishedAt)"') to filter out draft releases by inserting a select(.draft ==
false) (and also select(.prerelease == false) if prereleases must be excluded)
before mapping, so only non-draft (and optionally non-prerelease) releases are
emitted to the while read loop.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.