From f27fa42b878f15f8569494eb9bc17d691a7e0fb6 Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Tue, 21 Apr 2026 20:16:27 +0300 Subject: [PATCH] fix(ci): build release payload via heredoc, drop broken env-var passing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous attempt used `python3 -c "..." KEY=VALUE` which passes KEY=VALUE as positional args, not environment variables — the python block then crashed with KeyError: 'BODY' because nothing actually set it in the environment. Consolidate into a single heredoc-fed python3 block that reads RELEASE_NOTES from the already-exported env var and reads TAG/VERSION/ IS_PRE after an explicit `export`. Uses <<'PY' so shell metachars in the Python source (backticks, $, quotes) are not interpreted. Also drops the redundant intermediate BODY variable — body is built directly inside the single python invocation. --- .gitea/workflows/release.yml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 083300a..a6891fa 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -94,7 +94,9 @@ jobs: echo "No RELEASE_NOTES.md found" fi - BODY=$(python3 -c " + # Build release payload (avoids shell escaping & CLI length limits) + export TAG VERSION IS_PRE + python3 <<'PY' import json, os release_notes = os.environ.get('RELEASE_NOTES', '') @@ -106,22 +108,16 @@ jobs: if changelog: sections.append('## Changelog\n\n' + changelog) - print(json.dumps('\n\n'.join(sections))) - ") - - # Send body via file to avoid CLI length limits / shell escaping - python3 -c " - import json, os - body = os.environ['BODY'] payload = { 'tag_name': os.environ['TAG'], - 'name': f\"Notify Bridge {os.environ['VERSION']}\", - 'body': json.loads(body), + 'name': f"Notify Bridge {os.environ['VERSION']}", + 'body': '\n\n'.join(sections), 'draft': False, 'prerelease': os.environ['IS_PRE'] == 'true', } - open('/tmp/release-payload.json','w').write(json.dumps(payload)) - " BODY="$BODY" TAG="$TAG" VERSION="$VERSION" IS_PRE="$IS_PRE" + with open('/tmp/release-payload.json', 'w') as f: + json.dump(payload, f) + PY HTTP=$(curl -s -o /tmp/release-resp.json -w "%{http_code}" \ -X POST "$BASE_URL/releases" \