@@ -132,85 +132,52 @@ jobs:
132132 mkdir -p /tmp/release-notes
133133 chmod 777 /tmp/release-notes
134134
135+ # Initialize release notes content
136+ RELEASE_NOTES="## Release Notes"
137+ RELEASE_NOTES="${RELEASE_NOTES}"$'\n\n'
138+
135139 # Check if this is a PR from develop to main
136140 if [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.head.ref }}" == "develop" ]]; then
137- # Extract release notes from the PR body
138- PR_BODY="${{ github.event.pull_request.body }}"
139-
140- # Extract the content between "## Upcoming Changes" and the disclaimer
141- RELEASE_NOTES=$(echo "$PR_BODY" | sed -n '/## Upcoming Changes/,/This PR contains all changes/p' | sed '1d;$d')
142-
143- # Save to file for use in later steps (in temporary directory)
144- echo "$RELEASE_NOTES" > /tmp/release-notes/release_notes.md
141+ # Get the PR body content between markers using grep and sed
142+ PR_CONTENT=$(echo '${{ github.event.pull_request.body }}' | sed -n '/^## Changelog/,/^This PR contains all changes/p' | sed '$ d')
143+ RELEASE_NOTES="${RELEASE_NOTES}${PR_CONTENT}"
145144 else
146145 # Generate release notes in markdown format for release body
147- # Skip the npm command output by redirecting stderr to /dev/null and grep out the command line
148- npm run release:notes 2>/dev/null | grep -v "^>" > /tmp/release-notes/release_notes.md
146+ GENERATED_NOTES=$( npm run release:notes 2> /dev/null | grep -v "^>")
147+ RELEASE_NOTES="${RELEASE_NOTES}${GENERATED_NOTES}"
149148 fi
150149
151150 # Add @since updates section if there are any
152151 if [[ "${{ steps.update_since_tags.outputs.has_updates }}" == "true" ]]; then
153- # Read the summary from the previous step's output
154- SINCE_SUMMARY='${{ steps.update_since_tags.outputs.summary }}'
155- echo "" >> /tmp/release-notes/release_notes.md
156- echo "$SINCE_SUMMARY" >> /tmp/release-notes/release_notes.md
152+ RELEASE_NOTES="${RELEASE_NOTES}"$'\n\n'
153+ RELEASE_NOTES="${RELEASE_NOTES}${{ steps.update_since_tags.outputs.summary }}"
157154 fi
158155
159- # Check if the file has content
160- if [ ! -s /tmp/release-notes/release_notes.md ]; then
161- # If empty, provide a more informative default message
162- echo "## Release Notes" > /tmp/release-notes/release_notes.md
163- echo "" >> /tmp/release-notes/release_notes.md
164-
156+ # If no content was added, provide default message
157+ if [[ "${RELEASE_NOTES}" == "## Release Notes"$'\n\n' ]]; then
165158 if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
166- echo " This release was manually triggered with version bump type: ${{ github.event.inputs.release_type || 'auto' }}" >> /tmp/release-notes/release_notes.md
159+ RELEASE_NOTES="${RELEASE_NOTES} This release was manually triggered with version bump type: ${{ github.event.inputs.release_type || 'auto' }}"
167160 elif [[ "${{ github.event_name }}" == "schedule" ]]; then
168- echo " This is a scheduled release." >> /tmp/release-notes/release_notes.md
161+ RELEASE_NOTES="${RELEASE_NOTES} This is a scheduled release."
169162 else
170- echo " This release was triggered by merging a PR from develop to main." >> /tmp/release-notes/release_notes.md
163+ RELEASE_NOTES="${RELEASE_NOTES} This release was triggered by merging a PR from develop to main."
171164 fi
172165
173- echo "" >> /tmp/release-notes/release_notes.md
174- echo "No changesets were found for this release. This typically means:" >> /tmp/release-notes/release_notes.md
175- echo "- No features, fixes, or breaking changes were added, or" >> /tmp/release-notes/release_notes.md
176- echo "- The changes made did not require a changeset" >> /tmp/release-notes/release_notes.md
177- else
178- # If there is content, replace "Upcoming Changes" with "Release Notes" if present
179- sed -i 's/## Upcoming Changes/## Release Notes/g' /tmp/release-notes/release_notes.md
180-
181- # Remove the note about PR updates if present
182- sed -i '/This PR contains all changes that will be included in the next release/d' /tmp/release-notes/release_notes.md
166+ RELEASE_NOTES="${RELEASE_NOTES}"$'\n\n'
167+ RELEASE_NOTES="${RELEASE_NOTES}No changesets were found for this release. This typically means:"$'\n'
168+ RELEASE_NOTES="${RELEASE_NOTES}- No features, fixes, or breaking changes were added, or"$'\n'
169+ RELEASE_NOTES="${RELEASE_NOTES}- The changes made did not require a changeset"
183170 fi
184171
172+ # Save the release notes to a file
173+ echo "$RELEASE_NOTES" > $GITHUB_WORKSPACE/release_notes.md
174+
185175 # For debugging
186176 echo "Generated release notes:"
187- cat /tmp/release-notes/release_notes.md
188-
189- # Set the content for GitHub Actions output
190- # Properly escape the content for GitHub Actions
191- RELEASE_NOTES=$(cat /tmp/release-notes/release_notes.md)
192-
193- # First escape GitHub Actions special characters
194- RELEASE_NOTES="${RELEASE_NOTES//'%'/'%25'}"
195- RELEASE_NOTES="${RELEASE_NOTES//$'\r'/'%0D'}"
196-
197- # Then handle newlines last to prevent double-escaping
198- RELEASE_NOTES="${RELEASE_NOTES//$'\n'/'%0A'}"
199-
200- echo "content<<EOF" >> $GITHUB_OUTPUT
201- echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
202- echo "EOF" >> $GITHUB_OUTPUT
203-
204- # Ensure the temporary directory and files are readable by subsequent steps
205- chmod -R 755 /tmp/release-notes
206-
207- # List the contents of the directory to verify the file exists
208- echo "Verifying release notes file exists:"
209- ls -la /tmp/release-notes/
177+ cat $GITHUB_WORKSPACE/release_notes.md
210178
211- # Copy the release notes to a more permanent location in the workspace
212- # This ensures it's available even if the temporary directory is cleaned up
213- cp /tmp/release-notes/release_notes.md $GITHUB_WORKSPACE/release_notes.md
179+ # Set the content for GitHub Actions output using jq to properly escape the content
180+ echo "content=$(echo "$RELEASE_NOTES" | jq -Rsa .)" >> $GITHUB_OUTPUT
214181
215182 - name : Commit changes to main
216183 if : github.event_name == 'pull_request_target' || github.event_name == 'workflow_dispatch'
0 commit comments