Skip to content

Commit a3bf37a

Browse files
committed
MNT: Add update_changes script
1 parent b35978b commit a3bf37a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tools/update_changes.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
#
3+
# Collects the pull-requests since the latest release and
4+
# aranges them in the CHANGES.rst.txt file.
5+
#
6+
# This is a script to be run before releasing a new version.
7+
#
8+
# Usage /bin/bash update_changes.sh 1.0.1
9+
#
10+
11+
# Setting # $ help set
12+
set -u # Treat unset variables as an error when substituting.
13+
set -x # Print command traces before executing command.
14+
15+
# Check whether the Upcoming release header is present
16+
head -1 CHANGES.rst | grep -q Upcoming
17+
UPCOMING=$?
18+
if [[ "$UPCOMING" == "0" ]]; then
19+
head -n3 CHANGES.rst >> newchanges
20+
fi
21+
22+
# Elaborate today's release header
23+
HEADER="$1 ($(date '+%B %d, %Y'))"
24+
echo $HEADER >> newchanges
25+
echo $( printf "%${#HEADER}s" | tr " " "=" ) >> newchanges
26+
echo "" >> newchanges
27+
28+
# Search for PRs since previous release
29+
git log --grep="Merge pull request" `git describe --tags --abbrev=0`..HEAD --pretty='format: * %b %s' | sed 's/Merge pull request \#\([^\d]*\)\ from\ .*/(\#\1)/' >> newchanges
30+
echo "" >> newchanges
31+
echo "" >> newchanges
32+
33+
# Add back the Upcoming header if it was present
34+
if [[ "$UPCOMING" == "0" ]]; then
35+
tail -n+4 CHANGES.rst >> newchanges
36+
else
37+
cat CHANGES.rst >> newchanges
38+
fi
39+
40+
# Replace old CHANGES.rst with new file
41+
mv newchanges CHANGES.rst
42+

0 commit comments

Comments
 (0)