Skip to content

Commit

Permalink
Use jq to construct a valid json API message
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoHood committed Jan 30, 2021
1 parent e84a3b0 commit ae0a3ff
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gpgit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,13 @@ else
warning "Publishing release on default Github branch '${BRANCH}'."
fi

API_JSON="$(printf '{"tag_name": "%s","target_commitish": "%s","name": "%s","body": "%s","draft": false,"prerelease": %s}' \
"${TAG}" "${BRANCH}" "${TAG}" "${MESSAGE//$'\n'/'\n'}" "${PRERELEASE}")"
API_JSON="$(jq -n -C \
--arg tag_name "${TAG}" \
--arg target_commitish "${BRANCH}" \
--arg name "${TAG}" \
--arg body "${MESSAGE}" \
--arg prerelease "${PRERELEASE}" \
'{tag_name: $tag_name, target_commitish: $target_commitish, name: $name, body: $body, draft: false, prerelease: $prerelease }')"
if ! GITHUB_RELEASE="$(curl --proto-redir =https -s --data "${API_JSON}" \
"https://github.com/gitapi/repos/${GITHUB_REPO_NAME}/releases" \
-H "Accept: application/vnd.github.v3+json" \
Expand Down

0 comments on commit ae0a3ff

Please sign in to comment.