From 7c60120074293464b7f535086b64382ee1531611 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Tue, 10 Nov 2026 22:40:56 +0100 Subject: [PATCH 1/3] GH-55475: [Dev] Use merge button instead of merge script Document the "Squash and merge" button as the way to merge pull requests. The merge script is still available. Before the merge, the "PR Title" status of the Boring Cyborg app is a required status check on main: the pull request title must start with "GH-XXX" or "MINOR: ". The required check rejects direct pushes to main, so the release guide tells release managers to bump versions with a pull request. After the merge, a workflow for pushes to main assigns the issue to the pull request author if it isn't assigned, sets its milestone, closes it and comments which pull request resolved it. --- .asf.yaml | 11 +- .github/workflows/dev_pr_merged.yml | 110 ++++++++++++++++++ dev/README.md | 31 ++++- .../continuous_integration/overview.rst | 1 + docs/source/developers/overview.rst | 8 +- docs/source/developers/release.rst | 31 ++++- 6 files changed, 178 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/dev_pr_merged.yml diff --git a/.asf.yaml b/.asf.yaml index e4652b3f86ec..4893aa313b60 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -29,7 +29,16 @@ github: protected_branches: # protect main against force push - main: {} + main: + required_status_checks: + # Don't require branches to be up to date before merging. + strict: false + # The title check ("verifyTitles") of the Boring Cyborg app + # in .github/boring-cyborg.yml. The merge button is disabled + # while the pull request title doesn't start with "GH-XXX" + # or "MINOR: ". + contexts: + - PR Title collaborators: - alinaliBQ diff --git a/.github/workflows/dev_pr_merged.yml b/.github/workflows/dev_pr_merged.yml new file mode 100644 index 000000000000..f5bdcbd336ea --- /dev/null +++ b/.github/workflows/dev_pr_merged.yml @@ -0,0 +1,110 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: Dev PR merged + +on: + push: + branches: + - main + +permissions: + contents: read + pull-requests: read + issues: write + +jobs: + resolve: + name: Resolve + if: github.repository == 'apache/arrow' + runs-on: ubuntu-latest + steps: + # A pushed commit that isn't the merge commit of a pull request + # is ignored. + - name: Resolve issue + env: + COMMIT: ${{ github.sha }} + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + + pull_request=$( + gh api "repos/${GH_REPO}/commits/${COMMIT}/pulls" \ + --jq "map(select(.merge_commit_sha == \"${COMMIT}\"))[0] // empty") + if [ -z "${pull_request}" ]; then + echo "${COMMIT} isn't the merge commit of a pull request." + exit 0 + fi + title=$(jq -r .title <<< "${pull_request}") + if [[ ! "${title}" =~ ^GH-([0-9]+) ]]; then + echo "No GitHub issue in the title: ${title}" + exit 0 + fi + issue_number=${BASH_REMATCH[1]} + issue_path="repos/${GH_REPO}/issues/${issue_number}" + issue=$(gh api "${issue_path}") + if [ "$(jq 'has("pull_request")' <<< "${issue}")" = "true" ]; then + echo "#${issue_number} is a pull request, not an issue." + exit 0 + fi + + # Assign the issue to the pull request author if it isn't + # assigned to anyone. GitHub ignores this silently if the + # author can't be assigned. + if [ "$(jq '.assignees | length' <<< "${issue}")" -eq 0 ]; then + author=$(jq -r .user.login <<< "${pull_request}") + gh api "${issue_path}/assignees" -f "assignees[]=${author}" > /dev/null + fi + + # Use the milestone of the pull request. If the pull request + # doesn't have a milestone, keep the milestone of the issue. + # If the issue doesn't have a milestone either, use the next + # major release that doesn't have a maintenance branch yet + # like dev/merge_arrow_pr.py does. + milestone=$(jq -r '.milestone.number // empty' <<< "${pull_request}") + if [ -z "${milestone}" ] && \ + [ "$(jq '.milestone' <<< "${issue}")" = "null" ]; then + maintenance_versions=$( + gh api --paginate "repos/${GH_REPO}/git/matching-refs/heads/maint-" \ + --jq '.[].ref | ltrimstr("refs/heads/maint-")') + major_versions=$( + gh api --paginate "repos/${GH_REPO}/milestones?per_page=100" \ + --jq '.[] | select(.title | test("^[0-9]+\\.0\\.0$")) | "\(.title):\(.number)"' | + sort -V) + for major_version in ${major_versions}; do + if ! grep -qxF "${major_version%:*}" <<< "${maintenance_versions}"; then + milestone=${major_version#*:} + break + fi + done + fi + if [ -n "${milestone}" ]; then + gh api -X PATCH "${issue_path}" -F "milestone=${milestone}" > /dev/null + fi + + # Close the issue and comment which pull request resolved it + # after that. The merge script may have done them already. + if [ "$(jq -r .state <<< "${issue}")" != "closed" ]; then + gh issue close "${issue_number}" + fi + comment="Issue resolved by pull request $(jq -r .number <<< "${pull_request}")" + comments=$(gh api --paginate "${issue_path}/comments" --jq '.[].body') + if ! grep -qxF "${comment}" <<< "${comments}"; then + gh issue comment "${issue_number}" \ + --body "${comment}"$'\n'"$(jq -r .html_url <<< "${pull_request}")" + fi diff --git a/dev/README.md b/dev/README.md index 275e1ae5c92b..6e891b39bad7 100644 --- a/dev/README.md +++ b/dev/README.md @@ -33,8 +33,35 @@ committer. ## How to Merge a Pull Request -Please don't merge PRs using the GitHub Web interface. Instead, run -the following command: +Use the "Squash and merge" button of the GitHub Web interface. Before +you merge, check that: + +* The pull request title is what you want as the commit title: + `GH-XXX: [Component] Title` or `MINOR: [Component] Title`. The + merge is blocked by the "PR Title" status of the Boring Cyborg app + (`.github/boring-cyborg.yml`) unless the title starts with `GH-XXX` + or `MINOR: `. +* The pull request description is what you want as the commit + message. Remove leftovers of the pull request template in the + merge dialog if needed. You must remove CI directives such as + `[skip ci]`: GitHub doesn't run the workflow below for a commit + with them and you need to close the issue manually. + +After the merge, the "Dev PR merged" GitHub Actions workflow assigns +the issue `GH-XXX` to the pull request author if it isn't assigned to +anyone, sets its milestone, closes it and comments which pull request +resolved the issue. The milestone is taken from the pull request. Set +it before merging if the pull request isn't targeted for the next +major release. If the pull request doesn't have a milestone, the +existing issue milestone is retained; if the issue doesn't have a +milestone either, the next major release is used. This is only done +for pull requests to `main`. + +### Merge script + +The merge script is still available for now. It additionally adds +`Authored-by:`, `Co-authored-by:` and `Signed-off-by:` trailers to the +commit message. Run the following command: ```bash dev/merge_arrow_pr.sh diff --git a/docs/source/developers/continuous_integration/overview.rst b/docs/source/developers/continuous_integration/overview.rst index 4ae0e97297c4..ddb23693ba7c 100644 --- a/docs/source/developers/continuous_integration/overview.rst +++ b/docs/source/developers/continuous_integration/overview.rst @@ -53,6 +53,7 @@ The ``.yml`` files in ``.github/workflows`` are workflows which are run on GitHu - ``@github-actions crossbow submit ...`` - runs the specified Crossbow command - ``@github-actions rebase`` - rebases the PR onto the main branch - ``dev.yml`` - runs any time there is activity on a PR, or a PR is merged; it runs the linter and tests that the PR can be merged +- ``dev_pr_merged.yml`` - runs any time a PR is merged to the main branch; assigns the GitHub issue of the PR to the PR author if needed, sets its milestone and closes it PR housekeeping (component labels, PR title validation and the GitHub issue link in the PR description) is handled by the `Boring Cyborg `_ GitHub App, configured in ``.github/boring-cyborg.yml``. diff --git a/docs/source/developers/overview.rst b/docs/source/developers/overview.rst index 3b8775023236..53a40fa6f54a 100644 --- a/docs/source/developers/overview.rst +++ b/docs/source/developers/overview.rst @@ -133,8 +133,7 @@ in the end. To make the review process smooth for everyone, try to When tests are passing and the pull request has been approved by the interested parties, a `committer `_ -will merge the pull request. This is done with a -**command-line utility that does a squash merge**. +will merge the pull request. This is done with a **squash merge**. .. dropdown:: Details on squash merge :animate: fade-in-slide-down @@ -147,9 +146,8 @@ will merge the pull request. This is done with a cherry-pick individual patches onto a maintenance branch. Your pull request will appear in the GitHub interface to have been "merged". - In the commit message of that commit, the merge tool adds the pull request - description, a link back to the pull request, and attribution to the contributor - and any co-authors. + The commit message includes the pull request description, a link to the + pull request, and attribution to the contributor and any co-authors. .. _ai-generated-code: diff --git a/docs/source/developers/release.rst b/docs/source/developers/release.rst index fbce61ae9d17..835e081bd15e 100644 --- a/docs/source/developers/release.rst +++ b/docs/source/developers/release.rst @@ -105,7 +105,7 @@ assigned. archery release curate Ensure a major version milestone for a follow up release is created on GitHub. This will -automatically be used by our merge script as the new version for issues closed when +automatically be used on merging pull requests as the new version for issues closed when the maintenance branch is created. Patch Releases @@ -621,11 +621,30 @@ Be sure to go through on the following checklist: .. code-block:: Bash - # You can run the script with BUMP_TAG=0 and BUMP_PUSH=0 - # this will avoid default pushing to main and pushing the tag - # but you will require to push manually after reviewing the commits. - # dev/release/post-10-bump-versions.sh 10.0.0 11.0.0 - dev/release/post-10-bump-versions.sh X.Y.Z NEXT_X.NEXT_Y.NEXT_Z + # BUMP_PUSH=0 BUMP_TAG=0 dev/release/post-10-bump-versions.sh 10.0.0 11.0.0 + BUMP_PUSH=0 BUMP_TAG=0 dev/release/post-10-bump-versions.sh X.Y.Z NEXT_X.NEXT_Y.NEXT_Z + + ``BUMP_PUSH=0`` and ``BUMP_TAG=0`` are needed because we can't push + to ``main`` directly: ``main`` requires the "PR Title" status check. + The script only creates the commits in your local ``main``. You need + to push them to a branch, create a pull request from the branch with + a ``MINOR: [Release] Update versions for NEXT_X.NEXT_Y.NEXT_Z-SNAPSHOT`` + title and merge it: + + .. code-block:: Bash + + git push origin main:bump-versions-X.Y.Z + + After the pull request is merged, reset your local ``main``. For a + major release, you also need to tag the merged commit: + + .. code-block:: Bash + + git fetch upstream + git reset --hard upstream/main + # Only for a major release. Use the merged commit of the pull request. + git tag apache-arrow-NEXT_X.NEXT_Y.NEXT_Z.dev + git push upstream apache-arrow-NEXT_X.NEXT_Y.NEXT_Z.dev .. dropdown:: Update docs :animate: fade-in-slide-down From ffd59426651782b360a309991685d79db9f08dd4 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Wed, 18 Nov 2026 10:12:13 +0100 Subject: [PATCH 2/3] Reject WIP titles and don't push version bumps by default The "PR Title" check no longer accepts "WIP: GH-XXX" titles. They passed the required check but the "Dev PR merged" workflow ignored them, so the issue stayed open after the merge. dev/release/post-10-bump-versions.sh no longer pushes to main or creates the dev tag by default because the push is rejected by the required check. --- .github/boring-cyborg.yml | 5 ++++- dev/release/post-10-bump-versions.sh | 9 +++++++-- docs/source/developers/release.rst | 17 +++++++++-------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml index 8789531ae077..b19811992259 100644 --- a/.github/boring-cyborg.yml +++ b/.github/boring-cyborg.yml @@ -59,7 +59,10 @@ labelPRBasedOnFilePath: - "**/*.Rd" verifyTitles: - titleRegexp: '^(WIP:?\s*)?GH-[0-9]+|^MINOR: ' + # "PR Title" is a required status check of main in .asf.yaml. A + # "WIP: GH-XXX: ..." title must not pass: it blocks the merge until + # "WIP: " is removed. + titleRegexp: '^GH-[0-9]+|^MINOR: ' alwaysUsePrTitle: true validateEitherPrOrSingleCommitTitle: false statusTitle: "PR Title" diff --git a/dev/release/post-10-bump-versions.sh b/dev/release/post-10-bump-versions.sh index 958a536f243b..cd4c39fa2c6b 100755 --- a/dev/release/post-10-bump-versions.sh +++ b/dev/release/post-10-bump-versions.sh @@ -33,8 +33,13 @@ fi : ${BUMP_VERSION_POST_TAG:=${BUMP_DEFAULT}} : ${BUMP_DEB_PACKAGE_NAMES:=${BUMP_DEFAULT}} : ${BUMP_LINUX_PACKAGES:=${BUMP_DEFAULT}} -: ${BUMP_PUSH:=${BUMP_DEFAULT}} -: ${BUMP_TAG:=${BUMP_DEFAULT}} +# These are disabled by default because we can't push to the default +# branch directly: it requires the "PR Title" status check. Create a +# pull request from the commits and tag the merged commit instead. +# See also the "Bump versions" step in +# docs/source/developers/release.rst. +: ${BUMP_PUSH:=0} +: ${BUMP_TAG:=0} . $SOURCE_DIR/utils-prepare.sh diff --git a/docs/source/developers/release.rst b/docs/source/developers/release.rst index 835e081bd15e..f3332155bc88 100644 --- a/docs/source/developers/release.rst +++ b/docs/source/developers/release.rst @@ -621,14 +621,15 @@ Be sure to go through on the following checklist: .. code-block:: Bash - # BUMP_PUSH=0 BUMP_TAG=0 dev/release/post-10-bump-versions.sh 10.0.0 11.0.0 - BUMP_PUSH=0 BUMP_TAG=0 dev/release/post-10-bump-versions.sh X.Y.Z NEXT_X.NEXT_Y.NEXT_Z - - ``BUMP_PUSH=0`` and ``BUMP_TAG=0`` are needed because we can't push - to ``main`` directly: ``main`` requires the "PR Title" status check. - The script only creates the commits in your local ``main``. You need - to push them to a branch, create a pull request from the branch with - a ``MINOR: [Release] Update versions for NEXT_X.NEXT_Y.NEXT_Z-SNAPSHOT`` + # dev/release/post-10-bump-versions.sh 10.0.0 11.0.0 + dev/release/post-10-bump-versions.sh X.Y.Z NEXT_X.NEXT_Y.NEXT_Z + + The script only creates the commits in your local ``main``. It + doesn't push them and doesn't create a tag because we can't push to + ``main`` directly: ``main`` requires the "PR Title" status check. You + need to push the commits to a branch, create a pull request from the + branch with a + ``MINOR: [Release] Update versions for NEXT_X.NEXT_Y.NEXT_Z-SNAPSHOT`` title and merge it: .. code-block:: Bash From fab625796d4d6b9aecb301ae1a74ce1fb7b9177d Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Wed, 18 Nov 2026 11:45:51 +0100 Subject: [PATCH 3/3] Don't require the title check and read the issue from the commit Address review comments: * The "PR Title" status isn't a required status check of main. The Boring Cyborg app may be down when we need to merge. * Direct pushes to main work again, so the changes of dev/release/post-10-bump-versions.sh and the "Bump versions" step of the release guide are reverted. * The "Dev PR merged" workflow reads the issue and the pull request from the title of the pushed commit, "GH-XXX: ... (#YYY)", instead of asking GitHub for the pull request of the commit. The milestone of the pull request isn't used anymore. * dev/release/post-04-website.sh asks GitHub who merged the pull requests for "Patch Committers". Commits merged with the merge button don't have "Signed-off-by:" trailers. --- .asf.yaml | 11 +----- .github/boring-cyborg.yml | 3 -- .github/workflows/dev_pr_merged.yml | 58 ++++++++++++---------------- dev/README.md | 25 ++++++------ dev/release/post-04-website.sh | 31 +++++++++++++-- dev/release/post-10-bump-versions.sh | 9 +---- docs/source/developers/release.rst | 26 ++----------- 7 files changed, 70 insertions(+), 93 deletions(-) diff --git a/.asf.yaml b/.asf.yaml index 4893aa313b60..e4652b3f86ec 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -29,16 +29,7 @@ github: protected_branches: # protect main against force push - main: - required_status_checks: - # Don't require branches to be up to date before merging. - strict: false - # The title check ("verifyTitles") of the Boring Cyborg app - # in .github/boring-cyborg.yml. The merge button is disabled - # while the pull request title doesn't start with "GH-XXX" - # or "MINOR: ". - contexts: - - PR Title + main: {} collaborators: - alinaliBQ diff --git a/.github/boring-cyborg.yml b/.github/boring-cyborg.yml index b19811992259..b9097d96115b 100644 --- a/.github/boring-cyborg.yml +++ b/.github/boring-cyborg.yml @@ -59,9 +59,6 @@ labelPRBasedOnFilePath: - "**/*.Rd" verifyTitles: - # "PR Title" is a required status check of main in .asf.yaml. A - # "WIP: GH-XXX: ..." title must not pass: it blocks the merge until - # "WIP: " is removed. titleRegexp: '^GH-[0-9]+|^MINOR: ' alwaysUsePrTitle: true validateEitherPrOrSingleCommitTitle: false diff --git a/.github/workflows/dev_pr_merged.yml b/.github/workflows/dev_pr_merged.yml index f5bdcbd336ea..86de58101b6e 100644 --- a/.github/workflows/dev_pr_merged.yml +++ b/.github/workflows/dev_pr_merged.yml @@ -24,7 +24,6 @@ on: permissions: contents: read - pull-requests: read issues: write jobs: @@ -33,29 +32,25 @@ jobs: if: github.repository == 'apache/arrow' runs-on: ubuntu-latest steps: - # A pushed commit that isn't the merge commit of a pull request - # is ignored. + # A pushed commit that isn't the merge commit of a + # "GH-XXX: ... (#YYY)" pull request is ignored. - name: Resolve issue env: - COMMIT: ${{ github.sha }} + AUTHOR: ${{ github.event.head_commit.author.username }} GH_REPO: ${{ github.repository }} GH_TOKEN: ${{ github.token }} + MESSAGE: ${{ github.event.head_commit.message }} run: | set -euo pipefail - pull_request=$( - gh api "repos/${GH_REPO}/commits/${COMMIT}/pulls" \ - --jq "map(select(.merge_commit_sha == \"${COMMIT}\"))[0] // empty") - if [ -z "${pull_request}" ]; then - echo "${COMMIT} isn't the merge commit of a pull request." - exit 0 - fi - title=$(jq -r .title <<< "${pull_request}") - if [[ ! "${title}" =~ ^GH-([0-9]+) ]]; then - echo "No GitHub issue in the title: ${title}" + title=${MESSAGE%%$'\n'*} + title=${title%$'\r'} + if [[ ! "${title}" =~ ^GH-([0-9]+).*\ \(#([0-9]+)\)$ ]]; then + echo "Not the merge commit of a GH-XXX pull request: ${title}" exit 0 fi issue_number=${BASH_REMATCH[1]} + pull_request_number=${BASH_REMATCH[2]} issue_path="repos/${GH_REPO}/issues/${issue_number}" issue=$(gh api "${issue_path}") if [ "$(jq 'has("pull_request")' <<< "${issue}")" = "true" ]; then @@ -63,22 +58,19 @@ jobs: exit 0 fi - # Assign the issue to the pull request author if it isn't - # assigned to anyone. GitHub ignores this silently if the - # author can't be assigned. - if [ "$(jq '.assignees | length' <<< "${issue}")" -eq 0 ]; then - author=$(jq -r .user.login <<< "${pull_request}") - gh api "${issue_path}/assignees" -f "assignees[]=${author}" > /dev/null + # Assign the issue to the commit author, who is the pull + # request author for a squash merge, if it isn't assigned to + # anyone. GitHub ignores this silently if the author can't be + # assigned. + if [ -n "${AUTHOR}" ] && \ + [ "$(jq '.assignees | length' <<< "${issue}")" -eq 0 ]; then + gh api "${issue_path}/assignees" -f "assignees[]=${AUTHOR}" > /dev/null fi - # Use the milestone of the pull request. If the pull request - # doesn't have a milestone, keep the milestone of the issue. - # If the issue doesn't have a milestone either, use the next - # major release that doesn't have a maintenance branch yet - # like dev/merge_arrow_pr.py does. - milestone=$(jq -r '.milestone.number // empty' <<< "${pull_request}") - if [ -z "${milestone}" ] && \ - [ "$(jq '.milestone' <<< "${issue}")" = "null" ]; then + # Keep the milestone of the issue. If the issue doesn't have + # a milestone, use the next major release that doesn't have a + # maintenance branch yet like dev/merge_arrow_pr.py does. + if [ "$(jq '.milestone' <<< "${issue}")" = "null" ]; then maintenance_versions=$( gh api --paginate "repos/${GH_REPO}/git/matching-refs/heads/maint-" \ --jq '.[].ref | ltrimstr("refs/heads/maint-")') @@ -88,23 +80,21 @@ jobs: sort -V) for major_version in ${major_versions}; do if ! grep -qxF "${major_version%:*}" <<< "${maintenance_versions}"; then - milestone=${major_version#*:} + gh api -X PATCH "${issue_path}" \ + -F "milestone=${major_version#*:}" > /dev/null break fi done fi - if [ -n "${milestone}" ]; then - gh api -X PATCH "${issue_path}" -F "milestone=${milestone}" > /dev/null - fi # Close the issue and comment which pull request resolved it # after that. The merge script may have done them already. if [ "$(jq -r .state <<< "${issue}")" != "closed" ]; then gh issue close "${issue_number}" fi - comment="Issue resolved by pull request $(jq -r .number <<< "${pull_request}")" + comment="Issue resolved by pull request ${pull_request_number}" comments=$(gh api --paginate "${issue_path}/comments" --jq '.[].body') if ! grep -qxF "${comment}" <<< "${comments}"; then gh issue comment "${issue_number}" \ - --body "${comment}"$'\n'"$(jq -r .html_url <<< "${pull_request}")" + --body "${comment}"$'\n'"${GITHUB_SERVER_URL}/${GH_REPO}/pull/${pull_request_number}" fi diff --git a/dev/README.md b/dev/README.md index 6e891b39bad7..fcbabe97e3c6 100644 --- a/dev/README.md +++ b/dev/README.md @@ -38,24 +38,25 @@ you merge, check that: * The pull request title is what you want as the commit title: `GH-XXX: [Component] Title` or `MINOR: [Component] Title`. The - merge is blocked by the "PR Title" status of the Boring Cyborg app - (`.github/boring-cyborg.yml`) unless the title starts with `GH-XXX` - or `MINOR: `. + "PR Title" status of the Boring Cyborg app + (`.github/boring-cyborg.yml`) fails unless the title starts with + `GH-XXX` or `MINOR: ` but it doesn't block the merge. Keep the + ` (#YYY)` suffix that GitHub adds to the commit title in the merge + dialog: the workflow below needs it. * The pull request description is what you want as the commit message. Remove leftovers of the pull request template in the merge dialog if needed. You must remove CI directives such as `[skip ci]`: GitHub doesn't run the workflow below for a commit with them and you need to close the issue manually. -After the merge, the "Dev PR merged" GitHub Actions workflow assigns -the issue `GH-XXX` to the pull request author if it isn't assigned to -anyone, sets its milestone, closes it and comments which pull request -resolved the issue. The milestone is taken from the pull request. Set -it before merging if the pull request isn't targeted for the next -major release. If the pull request doesn't have a milestone, the -existing issue milestone is retained; if the issue doesn't have a -milestone either, the next major release is used. This is only done -for pull requests to `main`. +After the merge, the "Dev PR merged" GitHub Actions workflow reads +`GH-XXX` and `(#YYY)` from the commit title. It assigns the issue to +the pull request author if it isn't assigned to anyone, sets its +milestone, closes it and comments which pull request resolved the +issue. The existing issue milestone is retained: set it before merging +if the pull request isn't targeted for the next major release. If the +issue doesn't have a milestone, the next major release is used. This +is only done for pull requests to `main`. ### Merge script diff --git a/dev/release/post-04-website.sh b/dev/release/post-04-website.sh index 41a7ee4a04cf..defab0d23e11 100755 --- a/dev/release/post-04-website.sh +++ b/dev/release/post-04-website.sh @@ -75,10 +75,34 @@ rough_n_development_months=$(( git_tag=apache-arrow-${version} git_range=apache-arrow-${previous_version}..${git_tag} -committers_command_line="git shortlog -sn --group=trailer:signed-off-by ${git_range}" contributors_command_line="git shortlog -sn ${git_range}" -committers=$(${committers_command_line}) +# Count the pull requests of the commits in ${git_range} by who merged +# them. We ask GitHub because commits merged with the merge button +# don't have "Signed-off-by:" trailers. +list_committers() { + git log --pretty=%s ${git_range} | + sed -n -E 's/^.* \(#([0-9]+)\)$/\1/p' | + xargs -n 50 | + while read -r -a numbers; do + local query="query {repository(owner: \"apache\", name: \"arrow\") {" + local number + for number in "${numbers[@]}"; do + query+=" pr${number}: pullRequest(number: ${number})" + query+=" {mergedBy {login ... on User {name}}}" + done + query+="}}" + gh api graphql -f query="${query}" \ + --jq '.data.repository[].mergedBy | select(. != null) | + if (.name // "") == "" then .login else .name end' + done | + sort | + uniq -c | + sort -k1,1nr -k2 | + awk '{count = $1; sub(/^ *[0-9]+ /, ""); printf "%6d\t%s\n", count, $0}' +} + +committers=$(set -o pipefail; list_committers) contributors=$(${contributors_command_line}) n_commits=$(git log --pretty=oneline ${git_range} | wc -l) @@ -151,8 +175,7 @@ cat <> "${announce_file}" The following Apache committers merged contributed patches to the repository. -\`\`\`console -$ ${committers_command_line} +\`\`\`text ANNOUNCE echo "${committers}" >> "${announce_file}" diff --git a/dev/release/post-10-bump-versions.sh b/dev/release/post-10-bump-versions.sh index cd4c39fa2c6b..958a536f243b 100755 --- a/dev/release/post-10-bump-versions.sh +++ b/dev/release/post-10-bump-versions.sh @@ -33,13 +33,8 @@ fi : ${BUMP_VERSION_POST_TAG:=${BUMP_DEFAULT}} : ${BUMP_DEB_PACKAGE_NAMES:=${BUMP_DEFAULT}} : ${BUMP_LINUX_PACKAGES:=${BUMP_DEFAULT}} -# These are disabled by default because we can't push to the default -# branch directly: it requires the "PR Title" status check. Create a -# pull request from the commits and tag the merged commit instead. -# See also the "Bump versions" step in -# docs/source/developers/release.rst. -: ${BUMP_PUSH:=0} -: ${BUMP_TAG:=0} +: ${BUMP_PUSH:=${BUMP_DEFAULT}} +: ${BUMP_TAG:=${BUMP_DEFAULT}} . $SOURCE_DIR/utils-prepare.sh diff --git a/docs/source/developers/release.rst b/docs/source/developers/release.rst index f3332155bc88..da44d3e0f0c8 100644 --- a/docs/source/developers/release.rst +++ b/docs/source/developers/release.rst @@ -621,32 +621,12 @@ Be sure to go through on the following checklist: .. code-block:: Bash + # You can run the script with BUMP_TAG=0 and BUMP_PUSH=0 + # this will avoid default pushing to main and pushing the tag + # but you will require to push manually after reviewing the commits. # dev/release/post-10-bump-versions.sh 10.0.0 11.0.0 dev/release/post-10-bump-versions.sh X.Y.Z NEXT_X.NEXT_Y.NEXT_Z - The script only creates the commits in your local ``main``. It - doesn't push them and doesn't create a tag because we can't push to - ``main`` directly: ``main`` requires the "PR Title" status check. You - need to push the commits to a branch, create a pull request from the - branch with a - ``MINOR: [Release] Update versions for NEXT_X.NEXT_Y.NEXT_Z-SNAPSHOT`` - title and merge it: - - .. code-block:: Bash - - git push origin main:bump-versions-X.Y.Z - - After the pull request is merged, reset your local ``main``. For a - major release, you also need to tag the merged commit: - - .. code-block:: Bash - - git fetch upstream - git reset --hard upstream/main - # Only for a major release. Use the merged commit of the pull request. - git tag apache-arrow-NEXT_X.NEXT_Y.NEXT_Z.dev - git push upstream apache-arrow-NEXT_X.NEXT_Y.NEXT_Z.dev - .. dropdown:: Update docs :animate: fade-in-slide-down :class-title: sd-fs-5