55 types : [closed]
66 branches :
77 - master
8-
98jobs :
109 generate_notes :
1110 name : 📜 Generate Release Notes
12- if : github.event.pull_request.merged == true
1311 runs-on : ubuntu-latest
1412 outputs :
1513 release_date : ${{ steps.assemble.outputs.release_date }}
1614 last_updated_str : ${{ steps.assemble.outputs.last_updated_str }}
1715 steps :
18- - name : 📣 Get Merged PR Info
19- id : pr-info
20- uses : actions-ecosystem/action-get-merged-pull-request@v1
21- with :
22- github_token : ${{ secrets.GITHUB_TOKEN }}
23-
2416 - name : ✍️ Extract Sections from PR Body
2517 id : extract
18+ env :
19+ PR_BODY_RAW : ${{ github.event.pull_request.body }}
2620 run : |
27- read -r -d '' PR_BODY <<'EOF'
28- ${{ steps.pr-info.outputs.body }}
29- EOF
30-
31- VERSION_NOTES=$(echo "$PR_BODY" | awk '/### Version release notes/{flag=1;next}/### Improvements/{flag=0}flag')
32- echo "version_notes<<EOF" >> $GITHUB_OUTPUT
33- echo "$VERSION_NOTES" >> $GITHUB_OUTPUT
34- echo "EOF" >> $GITHUB_OUTPUT
35-
36- IMPROVEMENTS=$(echo "$PR_BODY" | awk '/### Improvements/{flag=1;next}/###|## /{flag=0}flag')
21+ # Clean and normalize the PR body
22+ PR_BODY=$(echo "$PR_BODY_RAW" | tr -d '\r')
23+
24+ # Extract improvements (after "### Improvements" and before "### Security Fixes")
25+ IMPROVEMENTS=$(echo "$PR_BODY" | awk '/^### Improvements/{flag=1;next}/^### Security Fixes/{flag=0}flag')
3726 echo "improvements<<EOF" >> $GITHUB_OUTPUT
3827 echo "$IMPROVEMENTS" >> $GITHUB_OUTPUT
3928 echo "EOF" >> $GITHUB_OUTPUT
40-
41- SECURITY_FIXES_CONTENT=""
42- if echo "$PR_BODY" | grep -q "### Security Fixes"; then
43- SECURITY_FIXES_RAW=$(echo "$PR_BODY" | awk '/### Security Fixes/{flag=1;next}/## /{flag=0}flag')
44- if [[ -n "$(echo "$SECURITY_FIXES_RAW" | xargs)" ]]; then
45- SECURITY_FIXES_CONTENT=$(printf '\n### Security Fixes\n%s' "$SECURITY_FIXES_RAW")
46- fi
47- fi
29+
30+ # Extract security fixes (after "### Security Fixes" and before "### Official")
31+ SECURITY_FIXES=$(echo "$PR_BODY" | awk '/^### Security Fixes/{flag=1;next}/^### Official/{flag=0}flag')
4832 echo "security_fixes<<EOF" >> $GITHUB_OUTPUT
49- echo "$SECURITY_FIXES_CONTENT" >> $GITHUB_OUTPUT
33+ echo "$SECURITY_FIXES" >> $GITHUB_OUTPUT
34+ echo "EOF" >> $GITHUB_OUTPUT
35+
36+ # Extract version release notes (after "### Version release notes" and before "## Steps")
37+ VERSION_NOTES=$(echo "$PR_BODY" | awk '/^### Version release notes/{flag=1;next}/^## Steps/{flag=0}flag')
38+ echo "version_notes<<EOF" >> $GITHUB_OUTPUT
39+ echo "$VERSION_NOTES" >> $GITHUB_OUTPUT
5040 echo "EOF" >> $GITHUB_OUTPUT
5141
5242 - name : 📦 Assemble Release Notes Block
@@ -61,18 +51,16 @@ jobs:
6151
6252 cat << EOF > release-notes-block.md
6353 ---
64- title: Release notes ${RELEASE_DATE}.0
65- publish_date: "${PUBLISH_DATE}"
66- ---
67-
68- ## Changelog
6954
70- ### Version release notes
71- ${{ steps.extract.outputs.version_notes }}
72-
73- ### Improvements
55+ Improvements
56+ ------------
7457 ${{ steps.extract.outputs.improvements }}
7558 ${{ steps.extract.outputs.security_fixes }}
59+
60+ Version release notes
61+ -------------------
62+ $(echo "${{ steps.extract.outputs.version_notes }}" | sed 's|https://\([^ ]*\)|[\1](https://\1)|g')
63+
7664 EOF
7765
7866 echo "::group::📜 New Release Notes Block"
@@ -109,44 +97,42 @@ jobs:
10997 NEW_NOTES_BLOCK_FILE="release-notes-block.md"
11098 TARGET_FILE_PATH="./docs-repo/docs/about/all/releases/image-releases/rabbitmq/release-notes-spryker-rabbitmq.md"
11199 NEW_LAST_UPDATED="${{ needs.generate_notes.outputs.last_updated_str }}"
100+ CURRENT_DATE=$(date +'%Y-%m-%d')
112101
113102 echo "Target file path: $TARGET_FILE_PATH"
114103 mkdir -p "$(dirname "$TARGET_FILE_PATH")"
115104
116105 if [ -f "$TARGET_FILE_PATH" ]; then
117- echo "File exists. Prepending new release block."
106+ echo "File exists. Updating last_updated, publish_date and prepending release block."
118107 EXISTING_CONTENT=$(cat "$TARGET_FILE_PATH")
119- UPDATED_CONTENT=$(echo "$EXISTING_CONTENT" | sed "0,/last_updated:.*/s/last_updated:.*/last_updated: ${NEW_LAST_UPDATED}/")
108+ UPDATED_CONTENT=$(echo "$EXISTING_CONTENT" | sed -e "0,/last_updated:.*/s/last_updated:.*/last_updated: ${NEW_LAST_UPDATED}/" -e "0,/publish_date:.*/s/publish_date:.*/publish_date: \"${CURRENT_DATE}\"/" )
120109
121110 line_num=$(echo "$UPDATED_CONTENT" | sed -n '/---/=' | sed -n '2p')
122111 MAIN_HEADER=$(echo "$UPDATED_CONTENT" | head -n "$line_num")
123112 EXISTING_BODY=$(echo "$UPDATED_CONTENT" | tail -n "+$((line_num + 1))")
124113
125- # Re-assemble the file with the new block prepended to the body
126114 {
127115 echo "$MAIN_HEADER"
128116 echo ""
129117 cat "$NEW_NOTES_BLOCK_FILE"
130- echo ""
131- echo "---"
132118 echo "$EXISTING_BODY"
133119 } > "$TARGET_FILE_PATH"
134120 else
135- echo "File does not exist. Creating new file."
136- cat << EOF > "$TARGET_FILE_PATH"
137- ---
138- title: Release notes for RabbitMQ image
139- description: This document describes the changes that have been recently released.
140- last_updated: ${NEW_LAST_UPDATED}
141- template: concept-topic-template
142- publish_date: "${PUBLISH_DATE}"
143- ---
144-
145- This document describes the changes that have been recently released.
146- For additional support with this content, contact our support.
147- If you found a new security vulnerability, contact us at **[email protected] **. 148-
149- EOF
121+ echo "File does not exist. Creating new file with static header and intro text ."
122+ printf '%s\n' \
123+ " ---" \
124+ " title: Release notes for spryker-rabbitmq docker image" \
125+ " description: This document describes the changes that have been recently released." \
126+ " last_updated: ${NEW_LAST_UPDATED}" \
127+ " template: concept-topic-template" \
128+ " publish_date: \ "${CURRENT_DATE}\"" \
129+ " ---" \
130+ "" \
131+ " This document describes the changes that have been recently released." \
132+ " For additional support with this content, contact our support." \
133+ " If you found a new security vulnerability, contact us at **[email protected] **." > "$TARGET_FILE_PATH" 134+
135+ echo "" >> "$TARGET_FILE_PATH"
150136 cat "$NEW_NOTES_BLOCK_FILE" >> "$TARGET_FILE_PATH"
151137 fi
152138
@@ -155,11 +141,11 @@ jobs:
155141 with :
156142 token : ${{ secrets.DOCS_REPO_PAT }}
157143 path : ./docs-repo
158- commit-message : " docs: Add release notes for ${{ needs.generate_notes.outputs.release_date }}"
159- branch : " docs/release-notes-${{ needs.generate_notes.outputs.release_date }}"
160- title : " Release Notes for ${{ needs.generate_notes.outputs.release_date }}"
144+ commit-message : " docs: Add release notes for spryker-rabbitmq ${{ needs.generate_notes.outputs.release_date }}"
145+ branch : " docs/docker-images/ release-notes-spryker-rabbitmq -${{ needs.generate_notes.outputs.release_date }}"
146+ title : " Release Notes for spryker-rabbitmq ${{ needs.generate_notes.outputs.release_date }}"
161147 body : |
162148 This PR contains the latest automated release notes generated from the source repository.
163149 Please review and merge. ✅
164- labels : " TW review needed, automation"
150+ labels : " automation"
165151 base : master
0 commit comments