Skip to content

Commit 028e2e2

Browse files
committed
Use jq instead of sed for cleaning up JSON
1 parent 763bb71 commit 028e2e2

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

.github/workflows/release.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,29 @@ jobs:
4343
- name: Extract release data
4444
id: release
4545
run: |
46-
echo "title=$(echo "${{ github.event.release.name }}" | sed 's/"/\\"/g')" >> $GITHUB_OUTPUT
47-
echo "body=$(echo "${{ github.event.release.body }}" | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/"/\\"/g')" >> $GITHUB_OUTPUT
46+
echo "title=${{ github.event.release.name }}" >> $GITHUB_OUTPUT
47+
echo "body<<EOF" >> $GITHUB_OUTPUT
48+
echo "${{ github.event.release.body }}" >> $GITHUB_OUTPUT
49+
echo "EOF" >> $GITHUB_OUTPUT
50+
51+
- name: Install jq
52+
run: sudo apt-get update && sudo apt-get install -y jq
4853

4954
- name: Publish changelog to Readme
5055
env:
5156
README_API_KEY: ${{ secrets.README_API_KEY }}
5257
run: |
58+
jq -n --arg title "Python Unified SDK ${{ steps.release.outputs.title }}" \
59+
--arg body "${{ steps.release.outputs.body }}" \
60+
'{
61+
author: { id: $authorId },
62+
title: $title,
63+
body: $body,
64+
privacy: { view: "public" }
65+
}' > payload.json
66+
5367
curl --location 'https://api.readme.com/v2/changelogs' \
54-
--header "Authorization: Bearer $README_API_KEY" \
55-
--header 'Content-Type: application/json' \
56-
--data '{
57-
"body": "${{ steps.release.outputs.body }}",
58-
"title": "Python Unified SDK ${{ steps.release.outputs.title }}",
59-
"privacy": {
60-
"view": "public"
61-
}
62-
}'
68+
--header "Authorization: Bearer $README_API_KEY" \
69+
--header 'Content-Type: application/json' \
70+
--data @payload.json
71+

0 commit comments

Comments
 (0)