Repository navigation
138 lines (123 loc) · 5.37 KB
/
Copy pathupdate-changelog.yml
File metadata and controls
138 lines (123 loc) · 5.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Update Changelog
# ⚠️ SCHEDULE DISABLED — superseded by consolidate-changelog.yml.
#
# This workflow scraped conventional-commit subjects and appended them to the
# CHANGELOG.md [Unreleased] block. It has NEVER worked: 100 out of 100 runs
# failed, with zero successes, from its first run on 2026-03-16 onwards.
#
# Three independent defects, all verified:
#
# 1. It ends in `git push origin develop`. develop is protected ("Changes must
# be made through a pull request") and github-actions[bot] is not in its
# bypass allowances, so this push can never succeed. Every run died here.
#
# 2. The since-ref is computed with
# git tag --sort=-version:refname | grep -E '^v?[0-9]+\.[0-9]+' | head -1
# which returns `v2.0` (2025-08-31) rather than the newest release `3.3.1`
# (2026-03-29), because the `v` prefix sorts after bare digits. The window
# is therefore 5515 commits instead of 795.
#
# 3. Scripts/generators/changelog_update_file.py dedups by PR number, but its filter
# keeps every entry that has NO PR number:
# if not prs_in_line or not prs_in_line.issubset(existing_prs):
# 979 of the 1126 collected entries have no `(#N)` ref, so they are
# re-appended on every run. Measured on the real repo, CHANGELOG.md grows
# 1265 → 2375 → 3357 → 4339 lines over three consecutive runs, unbounded.
#
# Defect 1 has been accidentally shielding the repo from defect 3. Fixing only
# the push would start corrupting CHANGELOG.md by ~982 lines per week.
#
# The fragment-based flow in consolidate-changelog.yml (added 4 days after this
# one) replaces it and fixes both content defects by design: PR numbers come
# from the fragment filename, and consolidation is idempotent. See
# .changelog/README.md.
#
# The schedule is commented out rather than the file deleted so a maintainer
# can decide whether to remove it outright. workflow_dispatch is kept so the
# generator can still be run deliberately — but note that defects 2 and 3 are
# NOT fixed here, so a manual run still produces a corrupting diff.
on:
# schedule:
# # Every Monday at 07:00 UTC — disabled, see the note above.
# - cron: '0 7 * * 1'
workflow_dispatch:
inputs:
since_ref:
description: 'Git ref to look back from (default: last semver tag)'
required: false
type: string
permissions:
contents: write
pull-requests: read
jobs:
update-changelog:
name: Refresh [Unreleased] section
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout develop
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: develop
- name: Compute since-ref
id: since
run: |
SINCE="${{ github.event.inputs.since_ref }}"
if [ -z "$SINCE" ]; then
# Last semver tag on develop
SINCE=$(git tag --sort=-version:refname | grep -E '^v?[0-9]+\.[0-9]+' | head -1)
if [ -z "$SINCE" ]; then
# Fall back to 30 days ago if no tags found
SINCE=$(git log --oneline --since="30 days ago" --format="%H" | tail -1)
fi
fi
echo "since=$SINCE" >> "$GITHUB_OUTPUT"
echo "Looking back from: $SINCE"
- name: Collect conventional commits since last tag
id: commits
env:
GH_TOKEN: ${{ github.token }}
run: |
SINCE="${{ steps.since.outputs.since }}"
# Extract conventional commits from both direct commits and merge commit bodies.
# Merge commits (PRs) have the conventional commit message in --format="%b" (body)
# or are squash-merged with the subject being the conventional commit.
{
# Direct commits with conventional commit subjects
git log "${SINCE}..HEAD" \
--no-merges \
--format="%s" \
| grep -E "^(feat|fix|refactor|perf|docs|chore|build|ci)(\([^)]+\))?:"
# Merge commits: body lines (squash details) and subject lines like "feat: ... (#N)"
git log "${SINCE}..HEAD" \
--merges \
--format="%s%n%b" \
| grep -E "^(feat|fix|refactor|perf|docs|chore|build|ci)(\([^)]+\))?:"
} | sort -u > /tmp/raw_commits.txt || true
echo "Raw commits found: $(wc -l < /tmp/raw_commits.txt)"
cat /tmp/raw_commits.txt
- name: Generate [Unreleased] entries
id: generate
run: python3 Scripts/generators/changelog_generate_entries.py
- name: Update CHANGELOG.md
run: |
# Only proceed if we have new entries
if [ ! -s /tmp/unreleased_entries.txt ]; then
echo "No new entries to add — skipping."
exit 0
fi
python3 Scripts/generators/changelog_update_file.py
- name: Commit changelog update
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git diff --quiet CHANGELOG.md; then
echo "No changes to CHANGELOG.md — nothing to commit."
exit 0
fi
git add CHANGELOG.md
git commit -m "chore(changelog): update [Unreleased] from recent commits" \
-m "Co-Authored-By: github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
git push origin develop
echo "CHANGELOG.md pushed to develop."