-
-
Notifications
You must be signed in to change notification settings - Fork 18
feat(changelog): Add changelog preview action and CLI command #669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add a new GitHub Action that posts changelog previews on PRs, showing contributors how their changes will appear in the changelog. Changes: - New `craft changelog` CLI command with `--pr` option for highlighting - New `changelog-preview/action.yml` that posts/updates PR comments - Shared `install/action.yml` for Craft installation (used by both actions) - Refactored main action.yml to use shared install action - Documentation in README and docs site
Contributor
|
Use local ./install action and inline the preview steps since the composite action references getsentry/craft/install@master which doesn't exist on master yet.
Contributor
Suggested Version Bump🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Documentation 📚🤖 This preview updates automatically when you update the PR. |
The previous approach relied on GitHub's associatedPullRequests API which only works for merged commits. Now we identify PR commits by comparing HEAD with the base branch and highlight those specific commits. Changes: - Replace --pr option with --base option for specifying the PR base branch - Highlight commits that are in HEAD but not in base (i.e., PR commits) - Update workflow and action to fetch base and use new option
- Add --until option to limit changelog range - Fetch current PR info from GitHub API - Add PR to appropriate category with highlighting - Uses blockquote style for highlighted entries
Craft now fetches PR info from GitHub API which includes the base branch, then computes the merge base internally. This simplifies the workflow.
Other repositories can now call this workflow directly:
```yaml
jobs:
changelog-preview:
uses: getsentry/craft/.github/workflows/changelog-preview.yml@v2
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
- Added workflow_call trigger with optional craft-version input
- Install Craft from release for external repos
- Build from source only for getsentry/craft (dogfooding)
Callers should use 'secrets: inherit' to pass secrets
BYK
commented
Dec 26, 2025
- Use install/action.yml instead of inline installation in workflow - Add build-from-source support to install action for craft repo - Remove duplicate changelog-preview/action.yml (use reusable workflow) - Add 'edited' and 'labeled' PR trigger types for title/label changes - Change 'push changes' to 'update the PR' in comment text - Use heredoc instead of temp file for gh api call - Reference getsentry/publish repo in docs as example - Document label exclusion option for skipping changelog entries
Can't reference install action from master as it's not merged yet. For external repos, install from release. For craft repo, build from source.
BYK
commented
Dec 26, 2025
- Use install action with PR ref in changelog-preview workflow - Use relative path ./install in main action.yml - Change CurrentPRInfo.number from string to number type - Make fetchPRInfo errors fatal (remove try/catch) - Make merge base computation errors fatal - Update all prInfo.number usages to convert to string where needed
- Add RawChangelogData interface for intermediate representation - Create generateRawChangelog function for data gathering - Create injectCurrentPR function to add PR to raw data - Create serializeChangelog function for markdown formatting - Update generateChangelogWithHighlight to use sandwich approach: 1. Generate raw changelog up to merge base 2. Inject current PR into the data 3. Serialize with PR highlighting - Remove highlight property from PullRequest interface - Make currentPRNumber required in generateChangelogWithHighlight - Use generateChangesetFromGit when --pr not specified
Using the PR's base branch tip directly (origin/{base.ref}) gives a more
accurate changelog preview, since it includes all commits currently on
the base branch that will be part of the final changelog when the PR
is merged.
Split RawChangelogData into: - RawChangelogData: just the changelog entries (categories, leftovers, config) - ChangelogStats: metrics for auto-versioning (bumpType, totalCommits, etc.) generateRawChangelog now returns RawChangelogResult containing both.
The function was only used in one place, so inline the logic directly.
- Split data gathering from categorization:
- fetchRawCommitInfo: fetches commit/PR data from git and GitHub
- categorizeCommits: groups commits into categories
- serializeChangelog: renders to markdown
- generateChangelogWithHighlight now:
1. Fetches raw commit info
2. Adds current PR with highlight flag to the list
3. Runs categorization on combined list (no duplicate logic)
4. Serializes to markdown
- Add highlight flag to PullRequest and Commit interfaces
- Serialization uses entry.highlight instead of comparing PR numbers
- Add --format json option to changelog command:
Returns { changelog, bumpType, totalCommits, matchedCommitsWithSemver }
- Use --format json to get bumpType from craft changelog - Display bump type with colored badge (🔴 Major, 🟡 Minor, 🟢 Patch) - Update docs to reflect new comment format
…mment - Version bump is now ## header appearing first - Use temp file instead of heredoc (safer with arbitrary content) - Use unique heredoc marker CRAFT_CHANGELOG_COMMENT_END - Use -F body=@file for gh api calls
betegon
approved these changes
Dec 26, 2025
BYK
added a commit
that referenced
this pull request
Dec 26, 2025
Follow up to #669. #skip-changelog
BYK
added a commit
that referenced
this pull request
Dec 26, 2025
Fixes the changelog preview workflow and `--pr` flag to properly respect the `#skip-changelog` magic word. ### Changes - Fix `inputs` context error in workflow (not available for `pull_request` trigger) - Add `prSkipped` field to JSON output when PR is excluded - Show "This PR will not appear in the changelog" message when PR is skipped - Consolidate skip logic into `shouldExcludePR` with new `body` parameter - Early-exit in `generateChangelogWithHighlight` to skip unnecessary work Follow-up to #669.
This was referenced Dec 26, 2025
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
craft changelogCLI command and a reusable GitHub Actions workflow that previews how PRs will appear in the changelog.New CLI Command
JSON Output
{ "changelog": "### New Features ✨\n\n> - feat: Add feature by @user in #123", "bumpType": "minor", "totalCommits": 15, "matchedCommitsWithSemver": 12 }Reusable Workflow
Other repos can use the changelog preview by adding:
Features
Example Comment
Architecture
Refactored changelog generation into clean separation of concerns:
The
generateChangelogWithHighlightfunction uses a "sandwich" approach:highlight: trueFiles Changed
src/commands/changelog.ts- New CLI commandsrc/utils/changelog.ts- Refactored with new architecture.github/workflows/changelog-preview.yml- Reusable workflowinstall/action.yml- Shared Craft installation actiondocs/src/content/docs/github-actions.md- DocumentationREADME.md- Updated with GitHub Actions section