fix(publish): avoid heredoc parsing in composite json helper
Replace the embedded python heredoc with python3 -c so the composite action remains valid YAML and shell across teacup parsing.
This commit is contained in:
@@ -44,28 +44,6 @@ runs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
parse_release_id() {
|
||||
local json_file="$1"
|
||||
|
||||
if command -v python3 >/dev/null 2>&1; then
|
||||
python3 - "$json_file" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
|
||||
with open(sys.argv[1], 'r', encoding='utf-8') as fh:
|
||||
payload = json.load(fh)
|
||||
|
||||
value = payload.get('id')
|
||||
if isinstance(value, int):
|
||||
print(value)
|
||||
PY
|
||||
return
|
||||
fi
|
||||
|
||||
# Fallback for environments without python3.
|
||||
sed -n 's/.*"id"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' "$json_file" | head -n 1
|
||||
}
|
||||
|
||||
provided="$(printf '%s' "${INPUT_VERSION:-}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||
if [[ -n "$provided" ]]; then
|
||||
normalized="${provided#v}"
|
||||
@@ -121,6 +99,18 @@ PY
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
parse_release_id() {
|
||||
local json_file="$1"
|
||||
|
||||
if command -v python3 >/dev/null 2>&1; then
|
||||
python3 -c 'import json, sys; payload = json.load(open(sys.argv[1], encoding="utf-8")); value = payload.get("id"); print(value if isinstance(value, int) else "")' "$json_file"
|
||||
return
|
||||
fi
|
||||
|
||||
# Fallback for environments without python3.
|
||||
sed -n 's/.*"id"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' "$json_file" | head -n 1
|
||||
}
|
||||
|
||||
raw_token="$(printf '%s' "${TOKEN:-}" | sed 's/^[[:space:]]\+//; s/[[:space:]]\+$//')"
|
||||
if [[ "$raw_token" =~ ^%\!t\(string=(.*)\)$ ]]; then
|
||||
raw_token="${BASH_REMATCH[1]}"
|
||||
|
||||
Reference in New Issue
Block a user