Skip to content

Commit 51988f8

Browse files
committed
ENH: Automatically update CHANGES after merge
1 parent e583788 commit 51988f8

File tree

3 files changed

+56
-4
lines changed

3 files changed

+56
-4
lines changed

.circleci/config.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,24 @@ jobs:
190190
fingerprints:
191191
- "ae:95:0c:cc:09:84:64:99:92:82:b7:b5:f4:a7:e9:23"
192192

193+
- run:
194+
name: Checkout origin/master
195+
command: |
196+
git config user.email "${GITHUB_EMAIL}"
197+
git config user.name "CircleCI Deploy"
198+
git fetch origin
199+
git checkout -f origin/master
200+
201+
- run:
202+
name: Update CHANGES if this is a merge commit
203+
command: |
204+
if (( $( git cat-file -p HEAD | sed -n '/^parent [0-9a-f]*$/p' | wc -l ) > 1 )); then
205+
bash update_changes.sh
206+
git add CHANGES.rst
207+
git commit -m "auto: Update CHANGES [skip ci]"
208+
git push origin HEAD:master
209+
fi
210+
193211
- run:
194212
name: Check whether skeleton needs an update
195213
command: |
@@ -201,10 +219,6 @@ jobs:
201219
- run:
202220
name: Push skeleton back to TemplateFlow's client repo
203221
command: |
204-
git config user.email "${GITHUB_EMAIL}"
205-
git config user.name "CircleCI Deploy"
206-
git fetch origin
207-
git checkout -f origin/master
208222
cp /tmp/resources/templateflow-skel.{zip,md5} templateflow/conf/
209223
git add templateflow/conf/templateflow-skel.{zip,md5}
210224
git commit -m "auto: Update S3 skeleton file and checksum [skip ci]"

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Upcoming release
2+
================
3+
4+
15
0.4.1 (July 20, 2019)
26
=====================
37

update_changes.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
# Search for PRs since previous release
23+
git show --pretty='format: * %b %s' HEAD | sed 's/Merge pull request \#\([^\d]*\)\ from\ .*/(\#\1)/' >> newchanges
24+
25+
# Add back the Upcoming header if it was present
26+
if [[ "$UPCOMING" == "0" ]]; then
27+
tail -n+4 CHANGES.rst >> newchanges
28+
else
29+
cat CHANGES.rst >> newchanges
30+
fi
31+
32+
# Replace old CHANGES.rst with new file
33+
mv newchanges CHANGES.rst
34+

0 commit comments

Comments
 (0)