Apache DataFusion SQL Query Engine
ARROW-1351: Update CHANGELOG.md in 00-prepare.sh when creating release candidate
Wes McKinney477726e1f43c
diff --git a/dev/release/00-prepare.sh b/dev/release/00-prepare.shindex c8d7909ba0..6dc3be1a5f 100644--- a/dev/release/00-prepare.sh+++ b/dev/release/00-prepare.sh@@ -27,7 +27,11 @@ if [ "$#" -eq 2 ]; thennextVersionSNAPSHOT=${nextVersion}-SNAPSHOTtag=apache-arrow-${version}- echo "prepare release ${version} rc ${rcnum} on tag ${tag} then reset to version ${nextVersionSNAPSHOT}"+ echo "Updating changelog for $version"+ # Update changelog+ $SOURCE_DIR/update-changelog.sh $version++ echo "prepare release ${version} rc ${rcnum} on tag ${tag} then reset to version ${nextVersionSNAPSHOT}"cd "${SOURCE_DIR}/../../java"@@ -38,8 +42,7 @@ if [ "$#" -eq 2 ]; thenecho "Finish staging binary artifacts by running: sh dev/release/01-perform.sh"-else+elseecho "Usage: $0 <version> <nextVersion>"exitfi-diff --git a/dev/make_changelog.py b/dev/release/changelog.pysimilarity index 73%rename from dev/make_changelog.pyrename to dev/release/changelog.pyindex b4b0070df8..65881503ab 100644--- a/dev/make_changelog.py+++ b/dev/release/changelog.py@@ -21,8 +21,12 @@# requirements: pip install jira# Set $JIRA_USERNAME, $JIRA_PASSWORD environment variables+from __future__ import print_function+from collections import defaultdict+from datetime import datetimefrom io import StringIO+import localeimport osimport sys@@ -39,6 +43,9 @@ asf_jira = jira.client.JIRA({'server': JIRA_API_BASE},basic_auth=(JIRA_USERNAME, JIRA_PASSWORD))+locale.setlocale(locale.LC_ALL, 'en_US.utf8')++def get_issues_for_version(version):jql = ("project=ARROW ""AND fixVersion='{0}' "@@ -99,19 +106,54 @@ def format_changelog_website(issues, out):out.write('\n')-if __name__ == '__main__':- if len(sys.argv) < 2:- print('Usage: make_changelog.py $FIX_VERSION [$IS_WEBSITE]')+def get_changelog(version, for_website=False):+ issues_for_version = get_issues_for_version(version)buf = StringIO()- for_website = len(sys.argv) > 2 and sys.argv[2] == '1'-- issues_for_version = get_issues_for_version(sys.argv[1])-if for_website:format_changelog_website(issues_for_version, buf)else:format_changelog_markdown(issues_for_version, buf)- print(buf.getvalue())+ return buf.getvalue()+++def append_changelog(version, changelog_path):+ new_changelog = get_changelog(version)++ with open(changelog_path, 'r') as f:+ old_changelog = f.readlines()++ result = StringIO()+ # Header+ print(''.join(old_changelog[:18]), file=result)++ # New version+ today = datetime.today().strftime('%d %B %Y')+ print('# Apache Arrow {0} ({1})'.format(version, today),+ end='', file=result)+ print('\n', file=result)+ print(new_changelog.replace('_', '\_'),+ end='', file=result)++ # Prior versions+ print(''.join(old_changelog[19:]), file=result)++ with open(changelog_path, 'w') as f:+ f.write(result.getvalue())+++if __name__ == '__main__':+ if len(sys.argv) < 2:+ print('Usage: changelog.py $FIX_VERSION [$IS_WEBSITE] '+ '[$CHANGELOG_TO_UPDATE]')++ for_website = len(sys.argv) > 2 and sys.argv[2] == '1'++ version = sys.argv[1]+ if len(sys.argv) > 3:+ changelog_path = sys.argv[3]+ append_changelog(version, changelog_path)+ else:+ print(get_changelog(version, for_website=for_website))diff --git a/dev/release/update-changelog.sh b/dev/release/update-changelog.shnew file mode 100755index 0000000000..d47c90606c--- /dev/null+++ b/dev/release/update-changelog.sh@@ -0,0 +1,31 @@+#!/bin/bash+#+# 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.+#+set -e++SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"++version=$1++CHANGELOG=$SOURCE_DIR/../../CHANGELOG.md++python $SOURCE_DIR/changelog.py $version 0 $CHANGELOG++git add $CHANGELOG+git commit -m "[Release] Update CHANGELOG.md for $version"