Skip to content

Commit cc521cd

Browse files
authored
chore(dev/release): add script to fix up milestone assignments (apache#3982)
Closes apache#3931.
1 parent 842233c commit cc521cd

File tree

2 files changed

+113
-7
lines changed

2 files changed

+113
-7
lines changed

dev/release/assign-milestone.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
# Assign the milestone on PRs/issues. This used to be done by CI, but since
21+
# we can no longer use pull_request_target workflows, do it manually instead.
22+
23+
set -euo pipefail
24+
25+
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
26+
source "${SOURCE_DIR}/utils-common.sh"
27+
28+
main() {
29+
# Scan the Git log for PRs since the last release
30+
local -r commits=$(git log --abbrev-commit --pretty=oneline apache-arrow-adbc-${PREVIOUS_RELEASE}..)
31+
local -r pr_numbers=$(echo "${commits}" | grep -E -o ' \(#[0-9]+\)$' | grep -E -o '[0-9]+')
32+
33+
local -r milestone=$(gh api graphql \
34+
--paginate \
35+
--jq ".data.repository.milestones.nodes.[]" \
36+
-f query="{
37+
repository(owner: \"apache\", name: \"arrow-adbc\") {
38+
milestones(states: [OPEN], first: 10, query: \"ADBC Libraries ${RELEASE}\") {
39+
nodes {
40+
id
41+
title
42+
}
43+
}
44+
}
45+
}")
46+
local -r milestone_title=$(echo "${milestone}" | jq -r '.title')
47+
48+
echo "Milestone to use: ${milestone_title}"
49+
read -p "Press ENTER to continue..." ignored
50+
51+
for pr_number in ${pr_numbers}; do
52+
local pr=$(gh api graphql \
53+
--paginate \
54+
--jq ".data.repository.pullRequest" \
55+
-f query="{
56+
repository(owner: \"apache\", name: \"arrow-adbc\") {
57+
pullRequest(number: ${pr_number}) {
58+
title
59+
milestone {
60+
title
61+
}
62+
closingIssuesReferences(first: 10) {
63+
nodes {
64+
number
65+
milestone {
66+
title
67+
}
68+
}
69+
}
70+
}
71+
}
72+
}")
73+
74+
local existing_milestone=$(echo "${pr}" | jq -r '.milestone.title')
75+
if [[ "${existing_milestone}" != "null" ]]; then
76+
echo "#${pr_number}: has milestone \`${existing_milestone}\`"
77+
else
78+
echo "#${pr_number}: assigning ${milestone_title}"
79+
gh pr edit "${pr_number}" --milestone "${milestone_title}"
80+
sleep 0.3
81+
fi
82+
83+
echo "${pr}" | jq -c '.closingIssuesReferences.nodes.[]' | while read -r issue; do
84+
local issue_number=$(echo "${issue}" | jq -r '.number')
85+
local issue_milestone=$(echo "${issue}" | jq -r '.milestone.title')
86+
if [[ "${issue_milestone}" != "null" ]]; then
87+
echo " linked issue #${issue_number}: has milestone \`${issue_milestone}\`"
88+
else
89+
echo " linked issue #${issue_number}: assigning ${milestone_title}"
90+
gh issue edit "${issue_number}" --milestone "${milestone_title}"
91+
sleep 0.3
92+
fi
93+
done
94+
95+
sleep 0.3
96+
done
97+
}
98+
99+
main "$@"

docs/source/development/releasing.rst

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,23 @@ Some steps of the release require being a committer or a PMC member.
7070
Before creating a Release Candidate
7171
===================================
7272

73-
Regenerate the LICENSE.txt (see CONTRIBUTING.md) and create a pull request if
74-
any changes were needed.
73+
1. Regenerate the LICENSE.txt (see CONTRIBUTING.md) and create a pull request if any changes were needed.
7574

76-
.. code-block::
75+
2. Set up your shell environment:
76+
77+
.. code-block::
78+
79+
# Setup gpg agent for signing artifacts
80+
source dev/release/setup-gpg-agent.sh
81+
82+
# Activate conda environment
83+
mamba activate adbc
84+
85+
3. Ensure merged pull requests and closed issues have their milestone set appropriately:
7786

78-
# Setup gpg agent for signing artifacts
79-
source dev/release/setup-gpg-agent.sh
87+
.. code-block::
8088
81-
# Activate conda environment
82-
mamba activate adbc
89+
./dev/release/assign-milestone.sh
8390
8491
Check Nightly Verification Job
8592
------------------------------

0 commit comments

Comments
 (0)