fix(ci): build release payload via heredoc, drop broken env-var passing
Release / release (push) Successful in 24s
Release / release (push) Successful in 24s
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.
This commit is contained in:
@@ -94,7 +94,9 @@ jobs:
|
|||||||
echo "No RELEASE_NOTES.md found"
|
echo "No RELEASE_NOTES.md found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BODY=$(python3 -c "
|
# Build release payload (avoids shell escaping & CLI length limits)
|
||||||
|
export TAG VERSION IS_PRE
|
||||||
|
python3 <<'PY'
|
||||||
import json, os
|
import json, os
|
||||||
|
|
||||||
release_notes = os.environ.get('RELEASE_NOTES', '')
|
release_notes = os.environ.get('RELEASE_NOTES', '')
|
||||||
@@ -106,22 +108,16 @@ jobs:
|
|||||||
if changelog:
|
if changelog:
|
||||||
sections.append('## Changelog\n\n' + 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 = {
|
payload = {
|
||||||
'tag_name': os.environ['TAG'],
|
'tag_name': os.environ['TAG'],
|
||||||
'name': f\"Notify Bridge {os.environ['VERSION']}\",
|
'name': f"Notify Bridge {os.environ['VERSION']}",
|
||||||
'body': json.loads(body),
|
'body': '\n\n'.join(sections),
|
||||||
'draft': False,
|
'draft': False,
|
||||||
'prerelease': os.environ['IS_PRE'] == 'true',
|
'prerelease': os.environ['IS_PRE'] == 'true',
|
||||||
}
|
}
|
||||||
open('/tmp/release-payload.json','w').write(json.dumps(payload))
|
with open('/tmp/release-payload.json', 'w') as f:
|
||||||
" BODY="$BODY" TAG="$TAG" VERSION="$VERSION" IS_PRE="$IS_PRE"
|
json.dump(payload, f)
|
||||||
|
PY
|
||||||
|
|
||||||
HTTP=$(curl -s -o /tmp/release-resp.json -w "%{http_code}" \
|
HTTP=$(curl -s -o /tmp/release-resp.json -w "%{http_code}" \
|
||||||
-X POST "$BASE_URL/releases" \
|
-X POST "$BASE_URL/releases" \
|
||||||
|
|||||||
Reference in New Issue
Block a user