Skip to content

Commit 2bba7c3

Browse files
authored
Support/fix auto generate cloud release notes (#743)
* chore: fix auto generate cloud release notes * chore: fix auto generate cloud release notes * chore: fix auto generate cloud release notes * chore: fix auto generate cloud release notes * chore: fix auto generate cloud release notes
1 parent 50a837d commit 2bba7c3

3 files changed

Lines changed: 95 additions & 50 deletions

File tree

.github/actions/components.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
kubeblocks-cloud: ../apecloud
2-
kubeblocks-console: ../kubeblocks-console
3-
kubeblocks: ../kubeblocks
4-
gemini: ../gemini
5-
ape-local-csi-driver: ../ape-local
6-
image:apecloud/oteld: ../oteld
7-
image:apecloud/dms: ../dms
8-
image:apecloud/servicemirror: ../servicemirror
9-
image:apecloud/ape-dts: ../ape-dts
10-
image:apecloud/apecloud-mcp: ../apecloud-mcp
1+
kubeblocks-cloud: ./apecloud
2+
kubeblocks-console: ./kubeblocks-console
3+
kubeblocks: ./kubeblocks
4+
gemini: ./gemini
5+
ape-local-csi-driver: ./ape-local
6+
image:apecloud/oteld: ./oteld
7+
image:apecloud/dms: ./dms
8+
image:apecloud/servicemirror: ./servicemirror
9+
image:apecloud/ape-dts: ./ape-dts
10+
image:apecloud/apecloud-mcp: ./apecloud-mcp

.github/utils/generate_release_notes.py

Lines changed: 63 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ def get_commits_between_tags(old_tag, new_tag, cwd=None, author=None):
155155
parts = line.split('|', 2)
156156
if len(parts) < 3:
157157
continue
158-
full_hash, subject, author = parts
158+
full_hash, subject, author_name = parts # FIX: renamed variable
159159
full_hash = full_hash.strip()
160160
subject = subject.strip()
161-
author = author.strip()
161+
author_name = author_name.strip()
162162

163-
mapped_author = map_author(author, author)
163+
mapped_author = map_author(author_name, author) # use outer 'author' dict
164164
pr_nums = extract_pr_numbers(subject)
165165
clean_msg = clean_subject(subject)
166166
commit_url = f"{repo_base_url}/commit/{full_hash}"
@@ -298,6 +298,63 @@ def auto_release_notes(manifest_path, comp_repo_map, image_repo_map, author_file
298298
if curr_yaml is None:
299299
sys.exit(f"Error: Could not read {manifest_path} from current HEAD")
300300

301+
# ---- list_only mode: exit early without any repo operations ----
302+
if list_only:
303+
# Get previous YAML for comparison
304+
if not force:
305+
prev_yaml = get_yaml_from_commit(manifest_path, "HEAD^")
306+
if prev_yaml is None:
307+
print("Warning: No previous version, assuming all components are new")
308+
prev_comp_versions = {}
309+
prev_yaml_full = None
310+
else:
311+
prev_comp_versions = extract_component_versions(prev_yaml)
312+
prev_yaml_full = prev_yaml
313+
else:
314+
# For --force --list-changed, still compare with HEAD^ (no repo tag lookup)
315+
prev_yaml = get_yaml_from_commit(manifest_path, "HEAD^")
316+
if prev_yaml is None:
317+
prev_comp_versions = {}
318+
prev_yaml_full = None
319+
else:
320+
prev_comp_versions = extract_component_versions(prev_yaml)
321+
prev_yaml_full = prev_yaml
322+
323+
curr_comp_versions = extract_component_versions(curr_yaml)
324+
325+
changed_names = set()
326+
# Component changes
327+
for (comp, idx), new_ver in curr_comp_versions.items():
328+
old_ver = prev_comp_versions.get((comp, idx))
329+
if old_ver is not None and str(old_ver) != str(new_ver):
330+
changed_names.add(comp)
331+
332+
# Image changes
333+
for image_name, parent_comp in MONITORED_IMAGES.items():
334+
curr_ver, _ = extract_image_version(curr_yaml, parent_comp, image_name)
335+
if curr_ver is None:
336+
continue
337+
if prev_yaml_full:
338+
prev_ver, _ = extract_image_version(prev_yaml_full, parent_comp, image_name)
339+
if prev_ver is not None and prev_ver != curr_ver:
340+
short_name = image_name.split('/')[-1]
341+
changed_names.add(short_name)
342+
else:
343+
# No previous YAML: assume changed
344+
short_name = image_name.split('/')[-1]
345+
changed_names.add(short_name)
346+
347+
# Version follow (no repo required)
348+
VERSION_FOLLOW = {"kubeblocks-console": "kubeblocks-cloud"}
349+
for child, parent in VERSION_FOLLOW.items():
350+
if parent in changed_names and child not in changed_names:
351+
changed_names.add(child)
352+
353+
output = ''.join(f'[{n}]' for n in sorted(changed_names))
354+
print(output if output else "No changes")
355+
return
356+
# ---- end list_only early exit ----
357+
301358
# For normal mode, get previous YAML
302359
if not force:
303360
prev_yaml = get_yaml_from_commit(manifest_path, "HEAD^")
@@ -307,6 +364,8 @@ def auto_release_notes(manifest_path, comp_repo_map, image_repo_map, author_file
307364
else:
308365
prev_yaml = None
309366

367+
# ... rest of original function unchanged ...
368+
310369
# Collect changes for components
311370
curr_comp_versions = extract_component_versions(curr_yaml)
312371

@@ -423,24 +482,7 @@ def sort_key(entry):
423482
changed_entries.sort(key=sort_key)
424483

425484
# ------------------------------------------------------------
426-
# If --list-changed, output compact name list and exit
427-
# ------------------------------------------------------------
428-
if list_only:
429-
names_set = set()
430-
for etype, name, idx, old_tag, new_tag, _ in changed_entries:
431-
if etype == 'component':
432-
names_set.add(name) # component name as-is
433-
else: # image
434-
short_name = name.split('/')[-1] # e.g. dms, oteld
435-
names_set.add(short_name)
436-
# Sort for deterministic output (optional, but convenient)
437-
sorted_names = sorted(names_set)
438-
output = ''.join(f'[{n}]' for n in sorted_names)
439-
print(output if output else "No changes")
440-
return
441-
442-
# ------------------------------------------------------------
443-
# Otherwise, generate full release notes (original behavior)
485+
# Generate full release notes (original behavior)
444486
# ------------------------------------------------------------
445487
print(f"Found {len(changed_entries)} version change(s):")
446488
for etype, name, idx, old, new, _ in changed_entries:

.github/workflows/release-notes.yml

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ on:
3737
default: 'main'
3838

3939
env:
40-
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
40+
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
4141
MANIFESTS_FILE: "./apecloud/manifests/deploy-manifests.yaml"
4242
COMPONENTS_FILE: "./.github/actions/components.yaml"
4343
MEMBERS_FILE: "./.github/actions/members.txt"
@@ -63,16 +63,17 @@ jobs:
6363
repository: apecloud/apecloud
6464
path: apecloud
6565
fetch-depth: 0
66-
token: ${{ env.GITHUB_TOKEN }}
66+
token: ${{ env.GH_TOKEN }}
6767
ref: "${{ inputs.RELEASE_VERSION }}"
6868

6969
- name: check change components
70-
run:
70+
run: |
7171
change_components=$( python3 .github/utils/generate_release_notes.py \
7272
--manifest "${{ env.MANIFESTS_FILE }}" \
7373
--component "${{ env.COMPONENTS_FILE }}" \
7474
--author "${{ env.MEMBERS_FILE }}" \
75-
--list-changed | (grep "[kubeblocks-cloud]" || true) )
75+
--list-changed | (grep "\[kubeblocks-cloud\]" || true) )
76+
echo "CHANGE_COMPONENTS=${change_components}"
7677
echo "LIST_CHANGED=${change_components}" >> "$GITHUB_ENV"
7778
7879
- name: checkout kubeblocks-console
@@ -81,7 +82,7 @@ jobs:
8182
repository: apecloud/kubeblocks-console
8283
path: kubeblocks-console
8384
fetch-depth: 0
84-
token: ${{ env.GITHUB_TOKEN }}
85+
token: ${{ env.GH_TOKEN }}
8586

8687
- name: checkout kubeblocks
8788
if: ${{ contains(env.LIST_CHANGED, '[kubeblocks]') || inputs.FRORCE }}
@@ -90,7 +91,7 @@ jobs:
9091
repository: apecloud/kubeblocks
9192
path: kubeblocks
9293
fetch-depth: 0
93-
token: ${{ env.GITHUB_TOKEN }}
94+
token: ${{ env.GH_TOKEN }}
9495

9596
- name: checkout gemini
9697
if: ${{ contains(env.LIST_CHANGED, '[gemini]') || inputs.FRORCE }}
@@ -99,7 +100,7 @@ jobs:
99100
repository: apecloud/gemini
100101
path: gemini
101102
fetch-depth: 0
102-
token: ${{ env.GITHUB_TOKEN }}
103+
token: ${{ env.GH_TOKEN }}
103104

104105
- name: checkout ape-local
105106
if: ${{ contains(env.LIST_CHANGED, '[ape-local-csi-driver]') || inputs.FRORCE }}
@@ -108,7 +109,7 @@ jobs:
108109
repository: apecloud/ape-local
109110
path: ape-local
110111
fetch-depth: 0
111-
token: ${{ env.GITHUB_TOKEN }}
112+
token: ${{ env.GH_TOKEN }}
112113

113114
- name: checkout oteld
114115
if: ${{ contains(env.LIST_CHANGED, '[oteld]') || inputs.FRORCE }}
@@ -117,7 +118,7 @@ jobs:
117118
repository: apecloud/oteld
118119
path: oteld
119120
fetch-depth: 0
120-
token: ${{ env.GITHUB_TOKEN }}
121+
token: ${{ env.GH_TOKEN }}
121122

122123
- name: checkout dms
123124
if: ${{ contains(env.LIST_CHANGED, '[dms]') || inputs.FRORCE }}
@@ -126,7 +127,7 @@ jobs:
126127
repository: apecloud/dms
127128
path: dms
128129
fetch-depth: 0
129-
token: ${{ env.GITHUB_TOKEN }}
130+
token: ${{ env.GH_TOKEN }}
130131

131132
- name: checkout servicemirror
132133
if: ${{ contains(env.LIST_CHANGED, '[servicemirror]') || inputs.FRORCE }}
@@ -135,7 +136,7 @@ jobs:
135136
repository: apecloud/servicemirror
136137
path: servicemirror
137138
fetch-depth: 0
138-
token: ${{ env.GITHUB_TOKEN }}
139+
token: ${{ env.GH_TOKEN }}
139140

140141
- name: checkout ape-dts
141142
if: ${{ contains(env.LIST_CHANGED, '[ape-dts]') || inputs.FRORCE }}
@@ -144,7 +145,7 @@ jobs:
144145
repository: apecloud/ape-dts
145146
path: ape-dts
146147
fetch-depth: 0
147-
token: ${{ env.GITHUB_TOKEN }}
148+
token: ${{ env.GH_TOKEN }}
148149

149150
- name: checkout apecloud-mcp
150151
if: ${{ contains(env.LIST_CHANGED, '[apecloud-mcp]') || inputs.FRORCE }}
@@ -153,20 +154,22 @@ jobs:
153154
repository: apecloud/apecloud-mcp
154155
path: apecloud-mcp
155156
fetch-depth: 0
156-
token: ${{ env.GITHUB_TOKEN }}
157+
token: ${{ env.GH_TOKEN }}
157158

158159
- name: generate release notes
159-
run:
160+
run: |
160161
gen_cmd="python3 .github/utils/generate_release_notes.py"
161-
gen_cmd="${gen_cmd} --manifest ${{ env.MANIFESTS_FILE }}"
162-
gen_cmd="${gen_cmd} --component ${{ env.COMPONENTS_FILE }}"
163-
gen_cmd="${gen_cmd} --author ${{ env.MEMBERS_FILE }}"
164-
gen_cmd="${gen_cmd} --summary ${{ env.RELEASE_NOTES_FILE }}"
165-
if [[ "${{ inputs.FRORCE }}" == "true" ]]; then
162+
gen_cmd="${gen_cmd} --manifest \"${{ env.MANIFESTS_FILE }}\""
163+
gen_cmd="${gen_cmd} --component \"${{ env.COMPONENTS_FILE }}\""
164+
gen_cmd="${gen_cmd} --author \"${{ env.MEMBERS_FILE }}\""
165+
gen_cmd="${gen_cmd} --summary \"${{ env.RELEASE_NOTES_FILE }}\""
166+
FRORCE="${{ inputs.FRORCE }}"
167+
if [[ "${FRORCE}" == "true" ]]; then
166168
gen_cmd="${gen_cmd} --force "
167169
fi
168170
echo "${gen_cmd}"
169171
eval "${gen_cmd}"
172+
cat "${{ env.RELEASE_NOTES_FILE }}"
170173
171174
- name: delete actions cache
172175
continue-on-error: true

0 commit comments

Comments
 (0)