Skip to content

Commit df3c4e0

Browse files
committed
feat: refactor JSON generation in release workflow using jq
1 parent e1679bd commit df3c4e0

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

.github/workflows/release.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,24 @@ jobs:
173173
WIN_URL="${BASE_URL}/${WIN_FILE}"
174174
MAC_URL="${BASE_URL}/${MAC_FILE}"
175175
PUB_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
176-
cat > doctorfill-latest.json <<EOF
177-
{
178-
"version": "${VERSION}",
179-
"notes": "See https://github.com/${REPO}/releases/tag/${TAG} for details.",
180-
"pub_date": "${PUB_DATE}",
181-
"platforms": {
182-
"windows-x86_64": {"url": "${WIN_URL}", "signature": "${WIN_SIG}"},
183-
"darwin-aarch64": {"url": "${MAC_URL}", "signature": "${MAC_SIG}"},
184-
"darwin-x86_64": {"url": "${MAC_URL}", "signature": "${MAC_SIG}"}
185-
}
186-
}
187-
EOF
176+
jq -n \
177+
--arg version "${VERSION}" \
178+
--arg notes "See https://github.com/${REPO}/releases/tag/${TAG} for details." \
179+
--arg pub_date "${PUB_DATE}" \
180+
--arg win_url "${WIN_URL}" \
181+
--arg win_sig "${WIN_SIG}" \
182+
--arg mac_url "${MAC_URL}" \
183+
--arg mac_sig "${MAC_SIG}" \
184+
'{
185+
version: $version,
186+
notes: $notes,
187+
pub_date: $pub_date,
188+
platforms: {
189+
"windows-x86_64": {url: $win_url, signature: $win_sig},
190+
"darwin-aarch64": {url: $mac_url, signature: $mac_sig},
191+
"darwin-x86_64": {url: $mac_url, signature: $mac_sig}
192+
}
193+
}' > doctorfill-latest.json
188194
CONTENT=$(jq -Rs . < doctorfill-latest.json)
189195
curl -s -X PATCH -H "Authorization: token ${GIST_TOKEN}" -H "Content-Type: application/json" -d "{\"files\":{\"doctorfill-latest.json\":{\"content\":${CONTENT}}}}" "https://api.github.com/gists/${GIST_ID}"
190196
echo "Gist updated for version ${VERSION}"

0 commit comments

Comments
 (0)