diff --git a/.github/config/markdownignore b/.github/config/markdownignore
index 61874c2a7a..00158608b8 100644
--- a/.github/config/markdownignore
+++ b/.github/config/markdownignore
@@ -1,3 +1,4 @@
examples/lib/tour/0*
docs/reference
docs/pluginreference
+hack/collapse/*
\ No newline at end of file
diff --git a/.github/config/wordlist.txt b/.github/config/wordlist.txt
index 3bb353cc37..d38b0d4469 100644
--- a/.github/config/wordlist.txt
+++ b/.github/config/wordlist.txt
@@ -27,6 +27,7 @@ bool
boolean
buildx
cas
+changelog
chocolateyinstall
cli
cliconfig
@@ -307,4 +308,4 @@ xml
yaml
yitsushi
yml
-yyyy
+yyyy
\ No newline at end of file
diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml
index e066e35b6d..ca8a9601cf 100644
--- a/.github/workflows/release-drafter.yaml
+++ b/.github/workflows/release-drafter.yaml
@@ -44,6 +44,7 @@ jobs:
fetch-tags: true
- name: Setup Release with gh
env:
+ COLLAPSE_THRESHOLD: 5
REF: ${{ github.ref }}
REPO: ${{ github.repository }}
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
@@ -81,6 +82,16 @@ jobs:
-q .body \
)
+ if [[ -z $notes ]]; then
+ echo "No release notes generated from API, failed"
+ exit 1
+ fi
+
+ echo "Auto-Collapsing release notes to reduce size"
+ echo $notes > $RUNNER_TEMP/release_notes.md
+ bash hack/collapse/auto_collapse.sh $RUNNER_TEMP/release_notes.md $RUNNER_TEMP/release_notes_processed.md ${{ env.COLLAPSE_THRESHOLD }}
+ notes=$(cat $RUNNER_TEMP/release_notes_processed.md)
+
echo "Release Notes generated for ${{env.RELEASE_VERSION}}:"
echo "${notes}"
diff --git a/hack/collapse/.gitignore b/hack/collapse/.gitignore
new file mode 100644
index 0000000000..edf5bf79b3
--- /dev/null
+++ b/hack/collapse/.gitignore
@@ -0,0 +1 @@
+test_example_collapsible.md
\ No newline at end of file
diff --git a/hack/collapse/auto_collapse.sh b/hack/collapse/auto_collapse.sh
new file mode 100644
index 0000000000..ce515c9400
--- /dev/null
+++ b/hack/collapse/auto_collapse.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+
+# Auto Collapse
+#This is a script that takes in
+# - a markdown file
+# - a designated output file
+# - the number of lines as a threshold on when to collapse a section.
+#
+# Sample
+# ./auto_collapse.sh test_example.md test_example_collapsible.md 10
+
+# Input and output files
+INPUT_FILE=${1:-"README.md"}
+OUTPUT_FILE=${2:-"README_collapsible.md"}
+THRESHOLD=${3:-10}
+
+# Ensure output file is empty initially
+rm -f "$OUTPUT_FILE"
+
+# Variables to track sections
+inside_section=false
+section_lines=()
+section_header=""
+
+INPUT="$(cat "$INPUT_FILE")"
+FULL_CHANGELOG=$(grep -E "Full Changelog" < "$INPUT_FILE")
+
+if [[ -z $FULL_CHANGELOG ]]; then
+ echo "Full Changelog not found in the input file."
+else
+ echo "Full Changelog found in the input file."
+ INPUT=$(echo "$INPUT" | sed '/Full Changelog/d')
+fi
+
+# Function to process and write a section
+write_section() {
+ local header="$1"
+ local lines=("${@:2}")
+ local num_lines=$((${#lines[@]}-1))
+
+ # Write the section header as is
+ echo "$header" >> "$OUTPUT_FILE"
+
+ if [[ $num_lines -gt $THRESHOLD ]]; then
+ # Collapse only the content with a dynamic summary
+ {
+ echo ""
+ echo "${num_lines} changes
"
+ echo ""
+ printf "%s\n" "${lines[@]}"
+ echo " "
+ } >> "$OUTPUT_FILE"
+ else
+ # Write the content as is if it's below the threshold
+ printf "%s\n" "${lines[@]}" >> "$OUTPUT_FILE"
+ fi
+}
+
+# Read the Markdown file line by line
+echo "${INPUT}" | while IFS= read -r line || [[ -n $line ]]; do
+ # Preserve comment blocks
+ if [[ $line =~ ^\
+
+## What's Changed
+### 🚀 Features
+* feat(log): log http requests for OCI and docker based on trace level by injecting a logger by @author in https://github.com/open-component-model/ocm/pull/1118
+### 🧰 Maintenance
+* chore: change guide for 0.18.0 by @author in https://github.com/open-component-model/ocm/pull/1066
+* chore: allow publishing to Brew via custom script by @author in https://github.com/open-component-model/ocm/pull/1059
+* chore: remove ocm inception during build CTF aggregation by @author in https://github.com/open-component-model/ocm/pull/1065
+* chore: release branches as `releases/vX.Y` instead of `releases/vX.Y.Z` by @author in https://github.com/open-component-model/ocm/pull/1071
+* chore: cleanup release action by @author in https://github.com/open-component-model/ocm/pull/1076
+* chore: bump version to 0.19.0-dev by @author in https://github.com/open-component-model/ocm/pull/1084
+* chore: disable mandatory period comments by @author in https://github.com/open-component-model/ocm/pull/1079
+
+**Full Changelog**: https://github.com/open-component-model/ocm/compare/v0.18...v0.19.0
+
\ No newline at end of file
diff --git a/hack/collapse/test_example_expected_collapsible.md b/hack/collapse/test_example_expected_collapsible.md
new file mode 100644
index 0000000000..c71baadc37
--- /dev/null
+++ b/hack/collapse/test_example_expected_collapsible.md
@@ -0,0 +1,22 @@
+
+
+## What's Changed
+
+### 🚀 Features
+* feat(log): log http requests for OCI and docker based on trace level by injecting a logger by @author in https://github.com/open-component-model/ocm/pull/1118
+### 🧰 Maintenance
+
+7 changes
+
+* chore: change guide for 0.18.0 by @author in https://github.com/open-component-model/ocm/pull/1066
+* chore: allow publishing to Brew via custom script by @author in https://github.com/open-component-model/ocm/pull/1059
+* chore: remove ocm inception during build CTF aggregation by @author in https://github.com/open-component-model/ocm/pull/1065
+* chore: release branches as `releases/vX.Y` instead of `releases/vX.Y.Z` by @author in https://github.com/open-component-model/ocm/pull/1071
+* chore: cleanup release action by @author in https://github.com/open-component-model/ocm/pull/1076
+* chore: bump version to 0.19.0-dev by @author in https://github.com/open-component-model/ocm/pull/1084
+* chore: disable mandatory period comments by @author in https://github.com/open-component-model/ocm/pull/1079
+
+
+
+
+**Full Changelog**: https://github.com/open-component-model/ocm/compare/v0.18...v0.19.0
\ No newline at end of file