Skip to content

split create tag and update changelog workflows to fix race condition#262

Merged
f-leu merged 3 commits intomainfrom
autochangelog
Jan 28, 2026
Merged

split create tag and update changelog workflows to fix race condition#262
f-leu merged 3 commits intomainfrom
autochangelog

Conversation

@f-leu
Copy link
Contributor

@f-leu f-leu commented Jan 28, 2026

Summary by CodeRabbit

  • Chores
    • Automated changelog updates now run in a dedicated workflow triggered when a release is published; it collects recent releases, formats entries, and creates a changelog pull request when needed.
    • CI workflow permissions tightened by removing unnecessary write access for pull-request operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@f-leu f-leu added the changelog:fixed Bug fixes label Jan 28, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

Moves changelog generation out of .github/workflows/create-tag-and-exit.yml and into a new .github/workflows/update-changelog.yml that runs on release.published, aggregates/formats releases, updates CHANGELOG.md, and opens a PR when needed.

Changes

Cohort / File(s) Summary
Workflow refactor
\.github/workflows/create-tag-and-exit.yml
Removed changelog generation & PR creation steps (56 lines) and removed pull-requests: write permission.
Changelog automation (new)
\.github/workflows/update-changelog.yml
Added workflow triggered on release.published that lists releases (paginated), formats entries (dates, heading levels), appends to CHANGELOG.md, commits to chore/update-changelog-${tag}, pushes, and conditionally creates a PR if none exists.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

changelog:added

Suggested reviewers

  • Tzvonimir
  • dray92

Poem

🐰 Hopping through tags with a pen so bright,
I gather releases by moonlit night,
I tidy headings, nibble stray lines neat,
Push a branch with carrots and a PR to greet —
Joyful changelogs make my heart skip a beat! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: splitting workflows and fixing a race condition in changelog handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@f-leu f-leu enabled auto-merge (squash) January 28, 2026 15:00
--base main \
--head "$BRANCH_NAME"
fi
# Changelog PR is created by the update-changelog.yml workflow
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove comment

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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).

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +35 to +38
# 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
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 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: true if the release is a draft (unpublished), else false. [1]
  • prerelease: true if the release is marked as a prerelease, else false. [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:


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.

@f-leu f-leu merged commit 16a1cf1 into main Jan 28, 2026
28 of 30 checks passed
@f-leu f-leu deleted the autochangelog branch January 28, 2026 15:37
@coderabbitai coderabbitai bot mentioned this pull request Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants