-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
tools: update create-release-proposal workflow
#56054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
54b66d9
a1c4b67
dd34941
cf9ed03
4ccd855
32c035b
0035942
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
create-release-proposal workflow
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,24 +10,87 @@ if [ -z "$RELEASE_DATE" ] || [ -z "$RELEASE_LINE" ]; then | |
| exit 1 | ||
| fi | ||
|
|
||
| createCommitAPICall() { | ||
| commit="${1:-HEAD}" | ||
| cat - <<'EOF' | ||
| mutation ($repo: String! $branch: String!, $parent: GitObjectID!, $commit_title: String!, $commit_body: String) { | ||
| createCommitOnBranch(input: { | ||
| branch: { | ||
| repositoryNameWithOwner: $repo, | ||
| branchName: $branch | ||
| }, | ||
| message: { | ||
| headline: $commit_title, | ||
| body: $commit_body | ||
| }, | ||
| expectedHeadOid: $parent, | ||
| fileChanges: { | ||
| additions: [ | ||
| EOF | ||
| git show "$commit" --diff-filter=d --name-only --format= | while read -r FILE; do | ||
| printf " { path: " | ||
| node -p 'JSON.stringify(process.argv[1])' "$FILE" | ||
| printf " , contents: \"" | ||
| base64 -w 0 -i "$FILE" | ||
| echo "\"}," | ||
| done | ||
| echo ' ], deletions: [' | ||
| git show "$commit" --diff-filter=D --name-only --format= | while read -r FILE; do | ||
| echo " $(node -p 'JSON.stringify(process.argv[1])' "$FILE")," | ||
| done | ||
| cat - <<'EOF' | ||
| ] | ||
| } | ||
| }) { | ||
| commit { | ||
| url | ||
| } | ||
| } | ||
| } | ||
| EOF | ||
| } | ||
|
|
||
| git node release --prepare --skipBranchDiff --yes --releaseDate "$RELEASE_DATE" | ||
| # We use it to not specify the branch name as it changes based on | ||
| # the commit list (semver-minor/semver-patch) | ||
| git config push.default current | ||
| git push | ||
|
|
||
| HEAD_BRANCH="$(git rev-parse --abbrev-ref HEAD)" | ||
| HEAD_SHA="$(git rev-parse HEAD^)" | ||
|
|
||
| TITLE=$(awk "/^## ${RELEASE_DATE}/ { print substr(\$0, 4) }" "doc/changelogs/CHANGELOG_V${RELEASE_LINE}.md") | ||
|
|
||
| # Use a temporary file for the PR body | ||
| TEMP_BODY="$(awk "/## ${RELEASE_DATE}/,/^<a id=/{ if (!/^<a id=/) print }" "doc/changelogs/CHANGELOG_V${RELEASE_LINE}.md")" | ||
|
|
||
| PR_URL="$(gh pr create --title "$TITLE" --body "$TEMP_BODY" --base "v$RELEASE_LINE.x")" | ||
|
|
||
| # Amend commit message so it contains the correct PR-URL trailer. | ||
| AMENDED_COMMIT_MSG="$(git log -1 --pretty=%B | sed "s|PR-URL: TODO|PR-URL: $PR_URL|")" | ||
| # Create the proposal branch | ||
| gh api \ | ||
| --method POST \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| "/repos/${GITHUB_REPOSITORY}/git/refs" \ | ||
| -f "ref=refs/heads/$HEAD_BRANCH" -f "sha=$HEAD_SHA" | ||
|
|
||
| # Replace "TODO" with the PR URL in the last commit | ||
| git commit --amend --no-edit -m "$AMENDED_COMMIT_MSG" || true | ||
| # Create the proposal PR | ||
| PR_URL="$(gh api \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don’t think
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh noes, I'm strongly -1 to this, as I don't think this is straightforward at all, the GitHub cli is super user-friendly and we already have people pushed away from contributing to this very script from the fact it's not using |
||
| --method POST \ | ||
| --jq .html_url \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| "/repos/${GITHUB_REPOSITORY}/pulls" \ | ||
| -f "title=$TITLE" -f "body=$TEMP_BODY" -f "head=$HEAD_BRANCH" -f "base=v$RELEASE_LINE.x")" | ||
|
|
||
| # Force-push the amended commit | ||
| git push --force | ||
| # Push the release commit to the proposal branch | ||
| createCommitAPICall | node --input-type=module -e 'console.log(JSON.stringify({ | ||
| query: Buffer.concat(await process.stdin.toArray()).toString(), | ||
| variables: { | ||
| repo: process.argv[1], | ||
| branch: process.argv[2], | ||
| parent: process.argv[3], | ||
| commit_title: process.argv[4], | ||
| commit_body: process.argv[5] | ||
| } | ||
| }))' \ | ||
| "$GITHUB_REPOSITORY" \ | ||
| "$HEAD_BRANCH" \ | ||
| "$HEAD_SHA" \ | ||
| "$(git log -1 HEAD --format=%s)" \ | ||
| "$(git log -1 HEAD --format=%b | sed "s|PR-URL: TODO|PR-URL: $PR_URL|")" \ | ||
| | curl -fS -H "Authorization: bearer ${BOT_TOKEN}" -X POST --data @- https://api.github.com/graphql | ||
Uh oh!
There was an error while loading. Please reload this page.