Skip to content

Commit 68a6661

Browse files
authored
Fix double-quote handling in release creation workflow (#751)
This PR escapes the release title’s double quotes and provides the release notes via a file, preventing shell interpretation errors in the gh release create command. Current workflow fails when (1) release title contains `"`: https://github.com/line/line-bot-sdk-java/actions/runs/12886931493/job/35928566569#step:6:3 or (2) PR title contains `"` (e.g. on reverting change, title is `revert "original title"`) (same as line/line-bot-sdk-java#1536)
1 parent 2e97b09 commit 68a6661

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

.github/workflows/create-draft-release.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,25 @@ jobs:
106106
console.log(`releaseNotes (modified): ${JSON.stringify(modifiedBody, null, 2)}`);
107107
core.setOutput("release_body", modifiedBody);
108108
109+
- name: Prepare Release Title
110+
id: title
111+
env:
112+
# "vX.Y.Z Release Title"
113+
RAW_TITLE: ${{ steps.calculate-version.outputs.new_version }} ${{ github.event.inputs.release_title }}
114+
run: |
115+
# Print RAW_TITLE safely, then escape double quotes
116+
SANITIZED_TITLE="$(printf '%s' "$RAW_TITLE" | sed 's/"/\\"/g')"
117+
echo "sanitized_title=$SANITIZED_TITLE" >> "$GITHUB_OUTPUT"
118+
119+
- name: Write Release Notes to File
120+
run: |
121+
echo "${{ steps.generate-release-notes.outputs.release_body }}" > release-notes.txt
122+
109123
- name: Create Draft Release
110124
run: |
111125
gh release create "${{ steps.calculate-version.outputs.new_version }}" \
112-
--title "${{ steps.calculate-version.outputs.new_version }} ${{ github.event.inputs.release_title }}" \
113-
--notes "${{ steps.generate-release-notes.outputs.release_body }}" \
126+
--title "${{ steps.title.outputs.sanitized_title }}" \
127+
--notes-file release-notes.txt \
114128
--draft \
115129
--repo "${{ github.repository }}"
116130
env:

0 commit comments

Comments
 (0)