review: code simplification and cleanup
This commit is contained in:
@@ -20,15 +20,25 @@ if [[ -n "${FRAG_FILE:-}" && -f "${FRAG_FILE}" ]]; then
|
||||
checksum="$(sha256sum "$FRAG_FILE" | cut -d' ' -f1)"
|
||||
fi
|
||||
|
||||
json_escape() {
|
||||
local s="$1"
|
||||
s="${s//\\/\\\\}"
|
||||
s="${s//\"/\\\"}"
|
||||
s="${s//$'\n'/\\n}"
|
||||
s="${s//$'\r'/\\r}"
|
||||
s="${s//$'\t'/\\t}"
|
||||
printf '%s' "$s"
|
||||
}
|
||||
|
||||
cat > "$out" <<JSON
|
||||
{
|
||||
"repo": "$FRAG_REPO",
|
||||
"sha": "$FRAG_SHA",
|
||||
"artifact": "$FRAG_ARTIFACT",
|
||||
"digest": "${FRAG_DIGEST:-}",
|
||||
"repo": "$(json_escape "$FRAG_REPO")",
|
||||
"sha": "$(json_escape "$FRAG_SHA")",
|
||||
"artifact": "$(json_escape "$FRAG_ARTIFACT")",
|
||||
"digest": "$(json_escape "${FRAG_DIGEST:-}")",
|
||||
"sha256": "$checksum",
|
||||
"publish_url": "${FRAG_URL:-}",
|
||||
"run_id": "${FRAG_RUN_ID:-}"
|
||||
"publish_url": "$(json_escape "${FRAG_URL:-}")",
|
||||
"run_id": "$(json_escape "${FRAG_RUN_ID:-}")"
|
||||
}
|
||||
JSON
|
||||
echo "emit-release-fragment: wrote $out"
|
||||
|
||||
Reference in New Issue
Block a user