Skip to content

Commit 51baa25

Browse files
Improve changelog agent: prerelease support, formatting fixes, publish trigger (#641)
- Support prerelease releases: update GitHub Release notes only (no CHANGELOG.md or PR) - Stable releases: update both CHANGELOG.md (via PR) and GitHub Release notes - Don't include version heading in GitHub Release notes (redundant with release title) - Omit 'Other changes' subheading when there are no highlighted features - Add 'New contributors' section for first-time contributors - Trigger changelog workflow from publish.yml for both latest and prerelease - Remove release:published trigger (GITHUB_TOKEN events don't trigger other workflows) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b380a82 commit 51baa25

File tree

3 files changed

+34
-59
lines changed

3 files changed

+34
-59
lines changed

.github/workflows/publish.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ on:
2222
permissions:
2323
contents: write
2424
id-token: write # Required for OIDC
25+
actions: write # Required to trigger changelog workflow
2526

2627
concurrency:
2728
group: publish
@@ -213,6 +214,10 @@ jobs:
213214
--target ${{ github.sha }}
214215
env:
215216
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
217+
- name: Trigger changelog generation
218+
run: gh workflow run release-changelog.lock.yml -f tag="v${{ needs.version.outputs.version }}"
219+
env:
220+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
216221
- name: Tag Go SDK submodule
217222
if: github.event.inputs.dist-tag == 'latest' || github.event.inputs.dist-tag == 'prerelease'
218223
run: |

.github/workflows/release-changelog.lock.yml

Lines changed: 8 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/release-changelog.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
---
2-
description: Generates a changelog from merged PRs/commits when a stable release is published, and opens a PR to update CHANGELOG.md
2+
description: Generates release notes from merged PRs/commits. Triggered by the publish workflow or manually via workflow_dispatch.
33
on:
4-
release:
5-
types: [published]
64
workflow_dispatch:
75
inputs:
86
tag:
97
description: "Release tag to generate changelog for (e.g., v0.1.30)"
108
required: true
119
type: string
12-
if: ${{ github.event.release.prerelease == false || github.event_name == 'workflow_dispatch' }}
1310
permissions:
1411
contents: read
1512
actions: read
@@ -31,23 +28,30 @@ timeout-minutes: 15
3128

3229
# Release Changelog Generator
3330

34-
You are an AI agent that generates a well-formatted changelog when a new stable release of the Copilot SDK is published. You update `CHANGELOG.md` in the repository and create a PR with the changes.
31+
You are an AI agent that generates well-formatted release notes when a release of the Copilot SDK is published.
32+
33+
- **For stable releases** (tag has no prerelease suffix like `-preview`): update `CHANGELOG.md` via a PR AND update the GitHub Release notes.
34+
- **For prerelease releases** (tag contains `-preview` or similar suffix): update the GitHub Release notes ONLY. Do NOT modify `CHANGELOG.md` or create a PR.
35+
36+
Determine which type of release this is by inspecting the tag or fetching the release metadata.
3537

3638
## Context
3739

3840
- Repository: ${{ github.repository }}
39-
- Release tag: ${{ github.event.release.tag_name || inputs.tag }}
40-
- Release name: ${{ github.event.release.name || inputs.tag }}
41+
- Release tag: ${{ github.event.inputs.tag }}
4142

42-
For `workflow_dispatch` runs, the `github.event.release.*` fields will be empty. In that case, use the GitHub API to fetch the release corresponding to `inputs.tag` to get its name, publish date, and other metadata.
43+
Use the GitHub API to fetch the release corresponding to `${{ github.event.inputs.tag }}` to get its name, publish date, prerelease status, and other metadata.
4344

4445
## Your Task
4546

4647
### Step 1: Identify the version range
4748

48-
1. The **new version** is the release tag: `${{ github.event.release.tag_name || inputs.tag }}`
49-
2. Read `CHANGELOG.md` and find the **most recent version heading** (a line matching `## [vX.Y.Z](...)`). Extract that version tag — this is the last documented release.
50-
3. If `CHANGELOG.md` has no version entries yet, find the previous stable release by listing releases and picking the most recent non-prerelease release before this one. If none exist, use the first commit in the repo as the starting point.
49+
1. The **new version** is the release tag: `${{ github.event.inputs.tag }}`
50+
2. Fetch the release metadata to determine if this is a **stable** or **prerelease** release.
51+
3. Determine the **previous version** to diff against:
52+
- **For stable releases**: find the previous **stable** release (skip prereleases). Check `CHANGELOG.md` for the most recent version heading (`## [vX.Y.Z](...)`), or fall back to listing releases via the API. This means stable changelogs include ALL changes since the last stable release, even if some were already mentioned in prerelease notes.
53+
- **For prerelease releases**: find the most recent release of **any kind** (stable or prerelease) that precedes this one. This way prerelease notes only cover what's new since the last release.
54+
4. If no previous release exists at all, use the first commit in the repo as the starting point.
5155

5256
### Step 2: Gather changes
5357

@@ -72,7 +76,9 @@ Only include changes that are **user-visible in the published SDK packages**. Sk
7276

7377
Additionally, identify **new contributors** — anyone whose first merged PR to this repo falls within this release range. You can determine this by checking whether the author has any earlier merged PRs in the repository.
7478

75-
### Step 4: Update CHANGELOG.md
79+
### Step 4: Update CHANGELOG.md (stable releases only)
80+
81+
**Skip this step entirely for prerelease releases.**
7682

7783
1. Read the current `CHANGELOG.md` file.
7884
2. Add the new version entry **at the top** of the file, right after the title/header.
@@ -90,7 +96,9 @@ Additionally, identify **new contributors** — anyone whose first merged PR to
9096
Omit this section if there are no new contributors.
9197
5. Make sure the existing content below is preserved exactly as-is.
9298

93-
### Step 5: Create a Pull Request
99+
### Step 5: Create a Pull Request (stable releases only)
100+
101+
**Skip this step entirely for prerelease releases.**
94102

95103
Use the `create-pull-request` output to submit your changes. The PR should:
96104
- Have a clear title like "Add changelog for vX.Y.Z"

0 commit comments

Comments
 (0)