fix(publish): stop sending target field in release payload
Prepare already creates and pushes the release tag, so publish should not retarget it. Sending target can trigger 403 on Gitea when tag retargeting is restricted. Build PATCH/POST payloads from tag_name + notes only.
This commit is contained in:
@@ -104,12 +104,6 @@ runs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Resolve the exact commit SHA the tag points to. Using git rev-list
|
|
||||||
# rather than github.sha avoids the common mismatch where the workflow
|
|
||||||
# was triggered from a pre-release commit but the tag was created on
|
|
||||||
# the subsequent release commit by the prepare job.
|
|
||||||
tag_sha="$(git rev-list -n 1 "${TAG_NAME}")"
|
|
||||||
|
|
||||||
release_notes="$(cat "$RELEASE_NOTES_FILE")"
|
release_notes="$(cat "$RELEASE_NOTES_FILE")"
|
||||||
escaped_release_notes="$(printf '%s' "$release_notes" | sed 's/\\/\\\\/g; s/"/\\"/g; :a;N;$!ba;s/\n/\\n/g')"
|
escaped_release_notes="$(printf '%s' "$release_notes" | sed 's/\\/\\\\/g; s/"/\\"/g; :a;N;$!ba;s/\n/\\n/g')"
|
||||||
release_api="${GITHUB_API_URL:-${GITHUB_SERVER_URL%/}/api/v1}/repos/${GITHUB_REPOSITORY}/releases"
|
release_api="${GITHUB_API_URL:-${GITHUB_SERVER_URL%/}/api/v1}/repos/${GITHUB_REPOSITORY}/releases"
|
||||||
@@ -133,7 +127,7 @@ runs:
|
|||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"${release_api}/${existing_release_id}" \
|
"${release_api}/${existing_release_id}" \
|
||||||
--data "{\"tag_name\":\"${TAG_NAME}\",\"target\":\"${tag_sha}\",\"name\":\"${TAG_NAME}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
--data "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
--output release.json
|
--output release.json
|
||||||
|
|
||||||
echo "id=$existing_release_id" >> "$GITHUB_OUTPUT"
|
echo "id=$existing_release_id" >> "$GITHUB_OUTPUT"
|
||||||
@@ -147,7 +141,7 @@ runs:
|
|||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"${release_api}" \
|
"${release_api}" \
|
||||||
--data "{\"tag_name\":\"${TAG_NAME}\",\"target\":\"${tag_sha}\",\"name\":\"${TAG_NAME}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
--data "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\",\"body\":\"${escaped_release_notes}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
--output release.json
|
--output release.json
|
||||||
|
|
||||||
release_id="$(sed -n 's/.*"id"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' release.json | head -n 1)"
|
release_id="$(sed -n 's/.*"id"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' release.json | head -n 1)"
|
||||||
|
|||||||
Reference in New Issue
Block a user