Skip to content

Commit

Permalink
gh: Fix release body sync to use release id
Browse files Browse the repository at this point in the history
Using tags does not work when trying to update a release.
  • Loading branch information
garazdawi committed Aug 13, 2024
1 parent a27050f commit 4c930e5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .github/scripts/sync-github-releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,14 @@ while [ "${TAG_URL}" != "" ]; do

## Check if we need to patch the body of the release
if ! echo "${RELEASE}" | jq -e 'select(.body != "")' > /dev/null; then
UPDATE_BODY=("${UPDATE_BODY[@]}" "${name}")
RELEASE_ID=$(echo "${RELEASE}" | jq '.id')
UPDATE_BODY=("${UPDATE_BODY[@]}" "${name}:${RELEASE_ID}")
if [[ ${RELEASE_VSN} -gt 26 ]]; then
RM="${name}.README.md"
else
RM="${name}.README"
fi
echo "Sync ${RM} for ${name} (for update of release body)"
echo "Sync ${RM} for ${name} (for update of release body, release id = ${RELEASE_ID})"
RI=("${RM}" "${RI[@]}")
fi

Expand Down Expand Up @@ -198,7 +199,9 @@ for name in "${CREATE_RELEASE[@]}"; do
_curl_post "${REPO}/releases" -d '{"tag_name":"'"${name}"'", "name":"OTP '"${stripped_name}\"${BODY}}"
done

for name in "${UPDATE_BODY[@]}"; do
for name_id in "${UPDATE_BODY[@]}"; do
name=$(echo "${name_id}" | awk -F: '{print $1}')
RELEASE_ID=$(echo "${name_id}" | awk -F: '{print $2}')
if [ -s downloads/"${name}.README.md" ]; then
README=$(cat downloads/"${name}.README.md")
README=$(_json_escape "${README}")
Expand All @@ -207,7 +210,7 @@ for name in "${UPDATE_BODY[@]}"; do
README=$(_json_escape "$(printf '```\n%s\n```' "${README}")")
fi
echo "Update body of ${name}"
_curl_patch "${REPO}/releases/tags/${name}" -d "{\"body\":${README}}"
_curl_patch "${REPO}/releases/${RELEASE_ID}" -d "{\"body\":${README}}"
done

UPLOADED=false
Expand Down

0 comments on commit 4c930e5

Please sign in to comment.