File 0390-gh-Fix-sync-of-descriptions-with-strange-bash-quotin.patch of Package erlang
From 36143291590b5ea8af73a4cc1d75865df023fb69 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Backstr=C3=B6m?= <lukas@erlang.org>
Date: Wed, 21 May 2025 22:16:04 +0200
Subject: [PATCH] gh: Fix sync of descriptions with strange bash quotings
Using variables as input into curl json is a bad idea, so we create a file
on disk instead and use that to patch the body of the release.
closes #9856
---
.github/scripts/sync-github-releases.sh | 27 +++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/.github/scripts/sync-github-releases.sh b/.github/scripts/sync-github-releases.sh
index 9126a5f52f..6d6c98cd04 100755
--- a/.github/scripts/sync-github-releases.sh
+++ b/.github/scripts/sync-github-releases.sh
@@ -241,11 +241,14 @@ for name in "${CREATE_RELEASE[@]}"; do
README=""
fi
if [ "${README}" != "" ]; then
- BODY=", \"body\":${RM}"
+ BODY=", \"body\":${README}"
else
BODY=""
fi
- _curl_post "${REPO}/releases" -d '{"tag_name":"'"${name}"'", "name":"OTP '"${stripped_name}\"${BODY}}"
+ TMP=$(mktemp)
+ printf '{"tag_name":"'"%s"'", "name":"OTP '"%s\"%s}" "${name}" "${stripped_name}" "${BODY}" > "${TMP}"
+ _curl_post "${REPO}/releases" --data-binary "@${TMP}"
+ rm -f ${TMP}
done
for name_id in "${UPDATE_BODY[@]}"; do
@@ -266,7 +269,10 @@ for name_id in "${UPDATE_BODY[@]}"; do
README=$(_json_escape "${README}")
fi
echo "Update body of ${name}"
- _curl_patch "${REPO}/releases/${RELEASE_ID}" -d "{\"body\":${README}}"
+ TMP=$(mktemp)
+ printf "{\"body\":%s}" "${README}" > "${TMP}"
+ _curl_patch "${REPO}/releases/${RELEASE_ID}" --data-binary "@${TMP}"
+ rm -f ${TMP}
done
UPLOADED=false
@@ -288,11 +294,16 @@ _upload_artifacts() {
UPLOAD_URL=$(echo "${RELEASE}" | jq -r ".upload_url" | sed 's/{.*//')
_upload() {
if [ -s downloads/${1} ]; then
- echo "Upload ${1}"
- UPLOADED=true
- _curl_post -H "Content-Type: ${2}" \
- "${UPLOAD_URL}?name=${1}" \
- --data-binary "@downloads/${1}"
+ ARTIFACT_ID=$(echo "${RELEASE}" | jq -r '.assets.[] | select(.name == "'"${1}"'")')
+ if [ "${ARTIFACT_ID}" = "" ]; then
+ echo "Upload ${1}"
+ UPLOADED=true
+ _curl_post -H "Content-Type: ${2}" \
+ "${UPLOAD_URL}?name=${1}" \
+ --data-binary "@downloads/${1}"
+ else
+ echo "Skipped upload of ${1}, it already exists"
+ fi
else
## See if we need to trigger any .exe to .zip convertions
if echo "${RI[@]}" | grep "otp_${2}_${stripped_name}.zip" > /dev/null; then
--
2.43.0