7474 date = ENV.fetch("DATE")
7575
7676 EMOJI_HEADINGS = ["### ✨", "### 🔄", "### 🐛", "### 🔧", "### 📚", "### 🧪", "### 📦", "### 🧱"].freeze
77+ PUBLIC_RELEASE_NOTE_EXCLUDED_HEADINGS = ["### 🔧 CI/CD"].freeze
7778
7879 def extract_unreleased(path)
7980 content = File.read(path)
8990 body
9091 end
9192
93+ def public_release_notes(markdown)
94+ skip_section = false
95+ markdown.each_line.each_with_object([]) do |line, lines|
96+ stripped = line.strip
97+ if stripped.start_with?("### ")
98+ skip_section = PUBLIC_RELEASE_NOTE_EXCLUDED_HEADINGS.include?(stripped)
99+ next if skip_section
100+ elsif stripped.start_with?("## ")
101+ skip_section = false
102+ end
103+
104+ lines << line unless skip_section
105+ end.join.strip
106+ end
107+
92108 gradle = File.read("gradle.properties")
93109 gradle.sub!(/^version\s*=.*$/, "version = #{version}")
94110 File.write("gradle.properties", gradle)
@@ -105,6 +121,8 @@ jobs:
105121
106122 notes_en = extract_unreleased("CHANGELOG.md")
107123 notes_zh = extract_unreleased("CHANGELOG_zh.md")
124+ public_notes_en = public_release_notes(notes_en)
125+ abort("Empty public release notes after filtering internal changelog sections") if public_notes_en.empty?
108126
109127 archive_unreleased("CHANGELOG.md", "## [#{version}] - #{date}", notes_en)
110128 archive_unreleased("CHANGELOG_zh.md", "## [#{version}]", notes_zh)
@@ -114,7 +132,7 @@ jobs:
114132 Prepare release `v#{version}`.
115133
116134 ## Release Notes
117- #{notes_en }
135+ #{public_notes_en }
118136 BODY
119137
120138 File.write("build/release-pr-body.md", body)
0 commit comments