Fix bash heredoc-inside-command-substitution by writing to temp file

This commit is contained in:
Keith Solomon
2026-08-11 13:27:24 -05:00
parent 57e1f63bcf
commit 123c0dbb7b
+5 -6
View File
@@ -95,7 +95,8 @@ jobs:
exit 1
fi
payload=$(TAG="$TAG" GH_SHA="$GITHUB_SHA" python3 - <<'PYEOF'
# Build the JSON payload to a temp file via Python heredoc.
python3 - > /tmp/release-payload.json <<'PYEOF'
import json, os
print(json.dumps({
"tag_name": os.environ["TAG"],
@@ -110,13 +111,12 @@ jobs:
"generate_release_notes": True,
}))
PYEOF
)
release_json=$(curl -fsS -X POST \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github+json" \
-H "Content-Type: application/json" \
-d "$payload" \
-d @/tmp/release-payload.json \
"${GH_API_URL}/repos/${REPO}/releases")
release_id=$(python3 -c 'import json,sys; print(json.loads(sys.stdin.read())["id"])' <<<"$release_json")
upload_url=$(python3 -c 'import json,sys; print(json.loads(sys.stdin.read())["upload_url"])' <<<"$release_json")
@@ -144,7 +144,7 @@ jobs:
API="${GH_API_URL%/}/api/v1"
fi
payload=$(TAG="$TAG" GH_SHA="$GITHUB_SHA" python3 - <<'PYEOF'
python3 - > /tmp/release-payload.json <<'PYEOF'
import json, os
print(json.dumps({
"tag_name": os.environ["TAG"],
@@ -158,12 +158,11 @@ jobs:
"prerelease": False,
}))
PYEOF
)
release_json=$(curl -fsS -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "$payload" \
-d @/tmp/release-payload.json \
"${API}/repos/${REPO}/releases")
release_id=$(python3 -c 'import json,sys; print(json.loads(sys.stdin.read())["id"])' <<<"$release_json")
if [ -z "$release_id" ]; then