From 30a138030aa2839129c1dadb7401c5dc867b5602 Mon Sep 17 00:00:00 2001 From: Dominika Date: Sat, 28 Nov 2020 23:42:14 -0500 Subject: [PATCH] [fix] Added more safety to uploadRelease.sh Signed-off-by: Dominika --- scripts/uploadRelease.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/uploadRelease.sh b/scripts/uploadRelease.sh index 1376612b2..bbdc9b136 100755 --- a/scripts/uploadRelease.sh +++ b/scripts/uploadRelease.sh @@ -15,13 +15,21 @@ check_var "3" "$3" || exit $? check_var "KAMI_REPO_MAJOR" "$KAMI_REPO_MAJOR" || exit $? check_var "KAMI_REPO_NIGHTLY" "$KAMI_REPO_NIGHTLY" || exit $? check_var "GITHUB_TOKEN" "$GITHUB_TOKEN" || exit $? +check_var "KAMI_DIR" "$KAMI_DIR" || exit $? +check_git || exit $? +cd "$KAMI_DIR" || exit $? +BRANCH="$(git symbolic-ref -q HEAD | sed "s/^refs\/heads\///g")" REPO="$KAMI_REPO_NIGHTLY" +check_var "git symbolic-ref -q HEAD" "$BRANCH" || exit $? + [ "$1" == "major" ] && REPO="$KAMI_REPO_MAJOR" # Create release -curl -s -H "Authorization: token $GITHUB_TOKEN" -X POST --data "$(generate_release_data "$KAMI_OWNER" "$REPO" "$3" "$2" "$3" "$5" "false" "false")" "https://api.github.com/repos/$KAMI_OWNER/$REPO/releases" || exit $? +# shellcheck disable=SC2001 +CHANGELOG="$(echo "$5" | sed "s/[\"';]//g")" +curl -s -H "Authorization: token $GITHUB_TOKEN" -X POST --data "$(generate_release_data "$KAMI_OWNER" "$REPO" "$3" "$BRANCH" "$3" "$CHANGELOG" "false" "false")" "https://api.github.com/repos/$KAMI_OWNER/$REPO/releases" || exit $? # Upload jar to release "$__scripts/uploadReleaseAsset.sh" github_api_token="$GITHUB_TOKEN" owner="$KAMI_OWNER" repo="$REPO" tag="$3" filename="$KAMI_DIR/build/libs/$4"