22
33set -xe
44
5+ GITHUB_REPOSITORY=${GITHUB_REPOSITORY:- nodejs/ node}
6+ BOT_TOKEN=${BOT_TOKEN:- }
7+
58RELEASE_DATE=$1
69RELEASE_LINE=$2
710
@@ -10,6 +13,11 @@ if [ -z "$RELEASE_DATE" ] || [ -z "$RELEASE_LINE" ]; then
1013 exit 1
1114fi
1215
16+ if [ -z " $GITHUB_REPOSITORY " ] || [ -z " $BOT_TOKEN " ]; then
17+ echo " Invalid value in env for GITHUB_REPOSITORY and BOT_TOKEN"
18+ exit 1
19+ fi
20+
1321createCommitAPICall () {
1422 commit=" ${1:- HEAD} "
1523 cat - << 'EOF '
3644 done
3745 echo ' ], deletions: ['
3846 git show " $commit " --diff-filter=D --name-only --format= | while read -r FILE; do
39- echo " $( node -p ' JSON.stringify(process.argv[1])' " $FILE " ) , "
47+ node -p ' " " + JSON.stringify(process.argv[1]) + "," ' " $FILE "
4048 done
4149 cat - << 'EOF '
4250 ]
@@ -78,7 +86,7 @@ PR_URL="$(gh api \
7886 -f " title=$TITLE " -f " body=$TEMP_BODY " -f " head=$HEAD_BRANCH " -f " base=v$RELEASE_LINE .x" ) "
7987
8088# Push the release commit to the proposal branch
81- createCommitAPICall | node --input-type=module -e ' console.log(JSON.stringify({
89+ createCommitAPICall HEAD | node --input-type=module -e ' console.log(JSON.stringify({
8290 query: Buffer.concat(await process.stdin.toArray()).toString(),
8391 variables: {
8492 repo: process.argv[1],
@@ -91,6 +99,6 @@ createCommitAPICall | node --input-type=module -e 'console.log(JSON.stringify({
9199 " $GITHUB_REPOSITORY " \
92100 " $HEAD_BRANCH " \
93101 " $HEAD_SHA " \
94- " $( git log -1 HEAD --format=%s) " \
95- " $( git log -1 HEAD --format=%b | sed " s|PR-URL: TODO|PR-URL: $PR_URL |" ) " \
102+ " $( git log -1 HEAD --format=%s || true ) " \
103+ " $( git log -1 HEAD --format=%b | sed " s|PR-URL: TODO|PR-URL: $PR_URL |" || true ) " \
96104| curl -fS -H " Authorization: bearer ${BOT_TOKEN} " -X POST --data @- https://api.github.com/graphql
0 commit comments