Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 13, 2025

Changes

Summary:
Adds a GitHub Action workflow that generates and posts changelog previews on PRs using semantic-release dry-run. The workflow uses a wildcard branch pattern to support GitHub's PR merge refs and includes all necessary setup steps.

Issues

Related issues:

  • Related to changelog preview feature request

Dependencies

Depends on:

N/A

Testing

How to test:

  1. Open a PR with conventional commit messages (e.g., feat:, fix:)
  2. Observe workflow run and comment posted with changelog preview
  3. Push additional commits and verify comment is updated (not duplicated)
  4. Test PR with non-conventional commits to see "no release" message

Test coverage:

  • Manual testing completed
  • Automated tests added/updated

Code Quality

Code review checklist:

  • Code follows existing patterns and conventions
  • Functions are small and focused
  • Types are properly defined
  • Error handling is appropriate
  • Documentation is updated if needed

Breaking Changes

Are there any breaking changes?

  • No breaking changes
  • Yes, breaking changes (describe below)

Migration notes:
N/A

Additional Context

Workflow behavior:

The workflow (changelog-preview.yaml):

  • Triggers on PR open/update/reopen events
  • Sets up Node.js environment and installs dependencies
  • Runs semantic-release with dry_run: true using a wildcard branch pattern to support any branch including GitHub's PR merge refs (refs/pull/*/merge)
  • Uses marocchino/sticky-pull-request-comment@v2 for idempotent comment updates
  • Shows version + release notes when commits trigger a release
  • Shows guidance message when commits don't follow conventional format
  • Includes error handling with informative failure messages

Key implementation details:

  • Wildcard branch pattern {name: '*', prerelease: true} allows semantic-release to run on any branch
  • Full git history is fetched (fetch-depth: 0) for proper semantic analysis
  • Dependencies are installed via npm ci to ensure release configuration is available

Example output:

When PR contains feat: or fix: commits:

## 📝 Changelog Preview

This PR will trigger a release with version **`2.11.0`**

### Release Notes
[Generated release notes from semantic-release]

When no release will be triggered:

## 📝 Changelog Preview

ℹ️ This PR will **not** trigger a new release.

To trigger a release, ensure your commits follow the Conventional Commits format...

When workflow fails:

## 📝 Changelog Preview

⚠️ Failed to generate changelog preview. Please check the workflow logs for details.
Original prompt

This section details on the original issue you should resolve

<issue_title>Changelog preview</issue_title>
<issue_description>## Motivation

Would be nice to have a preview of what the changelog will look like in every PR

Proposed Solution

Create a new GitHub Action that runs on every PR whenever a new commit is pushed to it. This action should then:

  • Run a semantic-release dry-run (don't publish a release, just generate a changelog for preview
  • Add a comment under the PR that includes the changelog that the current PR will generate
  • If there is already such comment, update it instead of adding a new one
  • If possible make sure only changes for this PR will be included (feature to base branch, not to master branch), but this is optional</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add changelog preview in pull requests Add changelog preview workflow for pull requests Dec 13, 2025
Copilot AI requested a review from pawcoding December 13, 2025 13:43
@pawcoding pawcoding force-pushed the copilot/add-changelog-preview-action branch from d93f6c7 to 5691abb Compare December 14, 2025 09:31
@github-actions
Copy link

github-actions bot commented Dec 14, 2025

📝 Changelog Preview

ℹ️ This PR will not trigger a new release.

To trigger a release, ensure your commits follow the Conventional Commits format with types that trigger releases (e.g., feat:, fix:, refactor:, etc.).

@pawcoding pawcoding force-pushed the copilot/add-changelog-preview-action branch 4 times, most recently from 1b0878b to bf3b014 Compare December 14, 2025 09:48
@pawcoding

This comment was marked as outdated.

This comment was marked as outdated.

@pawcoding pawcoding force-pushed the copilot/add-changelog-preview-action branch 6 times, most recently from 126abbc to ad397d2 Compare December 16, 2025 09:00
@pawcoding pawcoding force-pushed the copilot/add-changelog-preview-action branch from ad397d2 to 06c259e Compare December 16, 2025 09:03
@pawcoding pawcoding marked this pull request as ready for review December 16, 2025 09:04
@pawcoding pawcoding requested a review from Copilot December 16, 2025 09:04
@pawcoding pawcoding merged commit 9373f9b into master Dec 16, 2025
8 checks passed
@pawcoding pawcoding deleted the copilot/add-changelog-preview-action branch December 16, 2025 09:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a GitHub Actions workflow to generate and post changelog previews on pull requests using semantic-release in dry-run mode. The workflow automatically comments on PRs with either the expected changelog/version, a message indicating no release will be triggered, or an error message if the preview generation fails.

Key changes:

  • New GitHub Actions workflow (changelog-preview.yaml) that triggers on PR events and uses semantic-release to generate changelog previews
  • Modified release.config.cjs to support dry-run mode by conditionally disabling npm publishing based on a DRY_RUN environment variable

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
.github/workflows/changelog-preview.yaml New workflow that generates changelog previews on PRs using semantic-release dry-run mode and posts results as PR comments
release.config.cjs Added DRY_RUN environment variable handling to conditionally disable npm publishing during dry-run executions

I've identified several critical and moderate issues with the implementation that need to be addressed:

  1. Missing git history setup: The workflow needs fetch-depth: 0 to fetch full git history for semantic-release to properly analyze commits
  2. Missing Node.js setup and dependencies: The workflow lacks steps to setup Node.js, enable corepack, and install dependencies (which are required for semantic-release plugins)
  3. Branch configuration issue: The branches array configuration may not correctly identify commits to include in the changelog
  4. Missing version in preview: The changelog preview message doesn't display the version number that will be released
  5. String boolean handling: The dryRun environment variable check in release.config.cjs doesn't properly handle string-to-boolean conversion
  6. Inaccurate documentation: Comments in the workflow describe behavior that doesn't match the actual implementation

These issues should be resolved to ensure the workflow functions correctly and provides accurate changelog previews.

Comment on lines +37 to +38
'master',
'${{ github.head_ref }}'
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The branches configuration uses github.head_ref which only contains the branch name (e.g., 'feature-branch'), but semantic-release needs to analyze commits reachable from this ref. Since the workflow checks out the PR head and semantic-release analyzes from the base branch, this configuration may not correctly identify which commits to include in the changelog. Consider using a wildcard pattern like {name: '*', prerelease: true} to allow semantic-release to work with any branch, or ensure the base branch is properly configured for comparison.

Suggested change
'master',
'${{ github.head_ref }}'
"master",
{ "name": "*", "prerelease": true }

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changelog preview

2 participants