Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/changelog-preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: 📝 Changelog Preview

on:
pull_request:
types: [opened, synchronize, reopened]

env:
HUSKY: 0

jobs:
preview:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
# Checkout repository with full history for semantic-release
# This checks out the PR merge commit to analyze what would be released
- name: 📥 Checkout code
uses: actions/checkout@v5
with:
ref: ${{ github.head_ref }}
persist-credentials: false

# Run semantic-release in dry-run mode
# This analyzes commits from the base branch to the PR head
- name: 🔮 Generate changelog preview
id: changelog
uses: cycjimmy/semantic-release-action@v5
with:
semantic_version: 25
dry_run: true
ci: false
unset_gha_env: true
branches: |
[
'master',
'${{ github.head_ref }}'
Comment on lines +37 to +38
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.
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DRY_RUN: "true"

# Create or update PR comment with changelog
- name: 💬 Post changelog preview
uses: marocchino/sticky-pull-request-comment@v2
if: steps.changelog.outputs.new_release_version != ''
with:
header: changelog-preview
message: |
## 📝 Changelog Preview
${{ steps.changelog.outputs.new_release_notes }}
# Post comment if no release will be triggered
- name: 💬 Post no release message
uses: marocchino/sticky-pull-request-comment@v2
if: steps.changelog.outputs.new_release_version == ''
with:
header: changelog-preview
message: |
## 📝 Changelog Preview
ℹ️ This PR will **not** trigger a new release.
To trigger a release, ensure your commits follow the [Conventional Commits](https://www.conventionalcommits.org/) format with types that trigger releases (e.g., `feat:`, `fix:`, `refactor:`, etc.).
# Post comment if semantic-release fails
- name: 💬 Post error message
uses: marocchino/sticky-pull-request-comment@v2
if: failure() && steps.changelog.conclusion == 'failure'
with:
header: changelog-preview
message: |
## 📝 Changelog Preview
⚠️ Failed to generate changelog preview. Please check the [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
3 changes: 2 additions & 1 deletion release.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const branch = process.env.GITHUB_REF_NAME;
const customTag = process.env.CUSTOM_TAG;
const dryRun = process.env.DRY_RUN;

const assetsToUpdate = ["package.json", "package-lock.json"];
if (branch === "master") {
Expand Down Expand Up @@ -54,7 +55,7 @@ const plugins = [
[
"@semantic-release/npm",
{
npmPublish: true
npmPublish: !dryRun
}
],
[
Expand Down