github.com/kyma-project/kyma-environment-broker@v0.0.1/scripts/create_draft_release.sh (about) 1 #!/usr/bin/env bash 2 3 # This script returns the id of the draft release 4 5 # standard bash error handling 6 set -o nounset # treat unset variables as an error and exit immediately. 7 set -o errexit # exit immediately when a command fails. 8 set -E # needs to be set if we want the ERR trap 9 set -o pipefail # prevents errors in a pipeline from being masked 10 11 RELEASE_TAG=$1 12 13 REPOSITORY=${REPOSITORY:-kyma-project/kyma-environment-broker} 14 GITHUB_URL=https://api.github.com/repos/${REPOSITORY} 15 GITHUB_AUTH_HEADER="Authorization: Bearer ${GITHUB_TOKEN}" 16 17 JSON_PAYLOAD=$(jq -n \ 18 --arg tag_name "$RELEASE_TAG" \ 19 --arg name "$RELEASE_TAG" \ 20 '{ 21 "tag_name": $tag_name, 22 "name": $name, 23 "draft": true, 24 "generate_release_notes": true 25 }') 26 27 CURL_RESPONSE=$(curl -L \ 28 -X POST \ 29 -H "Accept: application/vnd.github+json" \ 30 -H "${GITHUB_AUTH_HEADER}" \ 31 -H "X-GitHub-Api-Version: 2022-11-28" \ 32 ${GITHUB_URL}/releases \ 33 -d "$JSON_PAYLOAD") 34 35 echo "$(echo $CURL_RESPONSE | jq -r ".id")"