@@ -10,24 +10,91 @@ if [ -z "$RELEASE_DATE" ] || [ -z "$RELEASE_LINE" ]; then
1010 exit 1
1111fi
1212
13+ buildMutationQuery () {
14+ repo=$1
15+ branch=$2
16+ commit=" ${3:- HEAD} "
17+ commit_title=" ${4:- $(git log -1 " $commit " --format=% s)} "
18+ commit_body=" ${5:- $(git log -1 " $commit " --format=% b)} "
19+ cat - << 'EOF '
20+ mutation ($repo: String! $branch: String!, $parent: GitObjectID!, $commit_title: String!, $commit_body: String) {
21+ createCommitOnBranch(input: {
22+ branch: {
23+ repositoryNameWithOwner: $repo,
24+ branchName: $branch
25+ },
26+ message: {
27+ headline: $commit_title,
28+ body: $commit_body
29+ },
30+ expectedHeadOid: $parent,
31+ fileChanges: {
32+ additions: [
33+ EOF
34+ git show " $commit " --diff-filter=d --name-only --format= | while read -r FILE; do
35+ echo " { path: "
36+ node -p ' JSON.stringify(process.argv[1])' " $FILE "
37+ printf " , contents: \" "
38+ base64 -b 0 -i " $FILE "
39+ echo " \" },"
40+ done
41+ echo ' ], deletions: ['
42+ git show " $commit " --diff-filter=D --name-only --format= | while read -r FILE; do
43+ echo " $( node -p ' JSON.stringify(process.argv[1])' " $FILE " ) ,"
44+ done
45+ cat - << 'EOF '
46+ ]
47+ }}) {
48+ commit {
49+ url
50+ }
51+ }
52+ }
53+ EOF
54+ node -p ' "variables " + JSON.stringify({
55+ repo: process.argv[1],
56+ branch: process.argv[2],
57+ parent: process.argv[3],
58+ commit_title: process.argv[4],
59+ commit_body: process.argv[5]
60+ }, undefined, 2)' " $repo " " $branch " " $( git rev-parse " ${commit} ^" ) " " $commit_title " " ${commit_body} "
61+ }
62+
63+ echo " No exit"
64+
1365git node release --prepare --skipBranchDiff --yes --releaseDate " $RELEASE_DATE "
14- # We use it to not specify the branch name as it changes based on
15- # the commit list (semver-minor/semver-patch)
16- git config push.default current
17- git push
66+
67+ HEAD_BRANCH=" $( git rev-parse --abbrev-ref HEAD) "
1868
1969TITLE=$( awk " /^## ${RELEASE_DATE} / { print substr(\$ 0, 4) }" " doc/changelogs/CHANGELOG_V${RELEASE_LINE} .md" )
2070
2171# Use a temporary file for the PR body
2272TEMP_BODY=" $( awk " /## ${RELEASE_DATE} /,/^<a id=/{ if (!/^<a id=/) print }" " doc/changelogs/CHANGELOG_V${RELEASE_LINE} .md" ) "
2373
24- PR_URL=" $( gh pr create --title " $TITLE " --body " $TEMP_BODY " --base " v$RELEASE_LINE .x" ) "
25-
26- # Amend commit message so it contains the correct PR-URL trailer.
27- AMENDED_COMMIT_MSG=" $( git log -1 --pretty=%B | sed " s|PR-URL: TODO|PR-URL: $PR_URL |" ) "
74+ # Create the proposal branch
75+ # gh api \
76+ # --method POST \
77+ # -H "Accept: application/vnd.github+json" \
78+ # -H "X-GitHub-Api-Version: 2022-11-28" \
79+ # "/repos/${GITHUB_REPOSITORY}/git/refs" \
80+ # -f "ref=refs/heads/$HEAD_BRANCH" -f "sha=$(git rev-parse HEAD^)"
2881
29- # Replace "TODO" with the PR URL in the last commit
30- git commit --amend --no-edit -m " $AMENDED_COMMIT_MSG " || true
82+ # Create the proposal PR
83+ # PR_URL="$(gh api \
84+ # --method POST \
85+ # --jq .html_url \
86+ # -H "Accept: application/vnd.github+json" \
87+ # -H "X-GitHub-Api-Version: 2022-11-28" \
88+ # "/repos/${GITHUB_REPOSITORY}/pulls" \
89+ # -f "title=$TITLE" -f "body=$TEMP_BODY" -f "head=$HEAD_BRANCH" -f "base=v$RELEASE_LINE.x")"
3190
32- # Force-push the amended commit
33- git push --force
91+ # Push the release commit to the proposal branch
92+ buildMutationQuery \
93+ " $GITHUB_REPOSITORY " \
94+ " $HEAD_BRANCH " \
95+ HEAD \
96+ " $( git log -1 HEAD --format=%s) " \
97+ " $( git log -1 HEAD --format=%b | sed " s|PR-URL: TODO|PR-URL: $PR_URL |" ) " \
98+ > query.gql
99+ # | node --input-type=module -e 'console.log(JSON.stringify({ query: Buffer.concat(await process.stdin.toArray()).toString() }))' \
100+ # | curl -fS -H "Authorization: bearer ${GH_TOKEN}" -X POST --data @- https://api.github.com/graphql
0 commit comments