A reusable GitHub Action that automatically comments on PRs and linked issues when they are included in a release.
When packages are published via Changesets:
- Parses each published package's CHANGELOG to find PR numbers in the latest version
- Groups PRs by number (handling cases where one PR affects multiple packages)
- Posts a comment on each PR with release info and CHANGELOG links
- Finds issues that each PR closes/fixes using GitHub's GraphQL API
- Posts comments on linked issues notifying them of the release
🎉 This PR has been released!
- [@tanstack/query-core@5.0.0](https://github.com/TanStack/query/blob/main/packages/query-core/CHANGELOG.md#500)
- [@tanstack/react-query@5.0.0](https://github.com/TanStack/query/blob/main/packages/react-query/CHANGELOG.md#500)
Thank you for your contribution!
🎉 The PR fixing this issue (#123) has been released!
- [@tanstack/query-core@5.0.0](https://github.com/TanStack/query/blob/main/packages/query-core/CHANGELOG.md#500)
Thank you for reporting!
Add this step to your .github/workflows/release.yml file after the changesets/action step:
- name: Run Changesets (version or publish)
id: changesets
uses: changesets/action@v1.5.3
with:
version: pnpm run changeset:version
publish: pnpm run changeset:publish
commit: 'ci: Version Packages'
title: 'ci: Version Packages'
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Comment on PRs about release
if: steps.changesets.outputs.published == 'true'
uses: TanStack/config/.github/comment-on-release@main
with:
published-packages: ${{ steps.changesets.outputs.publishedPackages }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}This action requires the GH_TOKEN input to authenticate with the GitHub API.
- Must be using Changesets for releases
- CHANGELOGs must include PR links in the format:
[#123](https://github.com/org/repo/pull/123) - Requires
pull-requests: writeandissues: writepermissions in the workflow - The
ghCLI must be available (automatically available in GitHub Actions)
| Input | Required | Description |
|---|---|---|
published-packages |
Yes | JSON string of published packages from changesets/action outputs |
The action:
- Receives the list of published packages from the Changesets action
- For each package, reads its CHANGELOG at
packages/{package-name}/CHANGELOG.md - Extracts PR numbers from the latest version section using regex
- Groups all PRs and tracks which packages they contributed to
- Posts a single comment per PR listing all packages it was released in
- For each PR, queries GitHub's GraphQL API to find linked issues (via
closes #Norfixes #Nkeywords) - Groups issues and tracks which PRs fixed them
- Posts comments on linked issues notifying them of the release
- Checks for duplicate comments to avoid spamming
- Uses the
ghCLI to post comments via the GitHub API
No comments are posted:
- Verify your CHANGELOGs have PR links in the correct format
- Check that
steps.changesets.outputs.publishedistrue - Ensure the workflow has
pull-requests: writeandissues: writepermissions
Script fails to find CHANGELOGs:
- The script expects packages at
packages/{package-name}/CHANGELOG.md - Package name should match after removing the scope (e.g.,
@tanstack/query-core→query-core)
Issues aren't being commented on:
- Verify that PRs use GitHub's closing keywords (
closes #N,fixes #N,resolves #N, etc.) in the PR description - Check that the linked issues exist and are accessible
- Ensure the
issues: writepermission is granted in the workflow