Skip to content

Commit 74af405

Browse files
Enhance changelog generation workflow: add unreleased section promotion logic and improve instruction clarity.
1 parent 0727662 commit 74af405

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

.github/workflows/addon.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,23 @@ jobs:
3333
- name: Install Claude Code
3434
run: npm install -g @anthropic-ai/claude-code
3535

36+
- name: Promote Unreleased section
37+
id: promote
38+
run: |
39+
VERSION="${GITHUB_REF_NAME#v}"
40+
if grep -q '^## Unreleased$' ha-addon/CHANGELOG.md; then
41+
# Rename the existing "## Unreleased" header to the new version so any
42+
# bullets already accumulated during development become this release's notes.
43+
sed -i "s/^## Unreleased$/## ${VERSION}/" ha-addon/CHANGELOG.md
44+
echo "promoted=true" >> "$GITHUB_OUTPUT"
45+
else
46+
echo "promoted=false" >> "$GITHUB_OUTPUT"
47+
fi
48+
3649
- name: Generate changelog
3750
env:
3851
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
52+
PROMOTED: ${{ steps.promote.outputs.promoted }}
3953
run: |
4054
VERSION="${GITHUB_REF_NAME#v}"
4155
PREV_TAG=$(git tag --sort=-version:refname | grep '^v' | sed -n '2p')
@@ -48,14 +62,20 @@ jobs:
4862
echo "" > /tmp/diffstat.txt
4963
fi
5064
65+
if [ "$PROMOTED" = "true" ]; then
66+
INSTRUCTION="A '## ${VERSION}' section already exists (promoted from an Unreleased section with hand-written notes). Review the commits and only APPEND bullets for changes not already covered. Do not duplicate existing bullets or reword them."
67+
else
68+
INSTRUCTION="Add a new '## ${VERSION}' section immediately after the '# Changelog' header."
69+
fi
70+
5171
cat <<EOF | claude -p --model claude-sonnet-4-6 --allowedTools Read,Edit || echo "::warning::Failed to generate changelog, skipping"
52-
Update ha-addon/CHANGELOG.md with a new ## ${VERSION} section after the '# Changelog' header.
72+
Update ha-addon/CHANGELOG.md. ${INSTRUCTION}
5373
Read /tmp/commits.txt for the commits and /tmp/diffstat.txt for changed files.
5474
Read ha-addon/CHANGELOG.md first to match the existing style.
5575
Guidelines:
5676
- Concise, user-facing bullet points
5777
- Note breaking changes with **Breaking:**
58-
- Do not modify any other sections
78+
- Do not modify any other version sections
5979
EOF
6080
6181
- name: Extract release notes

0 commit comments

Comments
 (0)