forked from awslabs/aws-postgresql-jdbc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_notes.sh
executable file
·59 lines (49 loc) · 1.89 KB
/
release_notes.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
CURRENT_VERSION=`grep pgjdbc.version gradle.properties`
VERS=${CURRENT_VERSION#"pgjdbc.version="}
DATE_YMD=$(date '+%Y-%m-%d')
RELEASE_FILE=$(find docs/_posts -name "*-$VERS-release.md" | head -n 1)
if [[ "x$RELEASE_FILE" == "x" ]]; then
RELEASE_FILE=docs/_posts/$DATE_YMD-$VERS-release.md
fi
echo file: $RELEASE_FILE
if [ -f $RELEASE_FILE ]; then
if [[ "x$1" == "x-o" ]]; then
echo Removing file $RELEASE_FILE
rm "$RELEASE_FILE"
fi
fi
if [ -f $RELEASE_FILE ]; then
echo File $RELEASE_FILE already exists. If you want to overwrite it, pass -o parameter
else
# Makes all the output get printed to the file as well (concept from http://stackoverflow.com/a/3403786/267224)
exec > >(tee -a $RELEASE_FILE)
exec 2>&1
fi
PREV_VERSION=`git describe --match 'REL*' --abbrev=0`
echo ---
echo title: "PostgreSQL JDBC Driver ${VERS} Released"
echo date: $(date '+%Y-%m-%d %H:%M:%S %z')
echo categories:
echo ' - new_release'
echo version: ${VERS}
echo ---
echo **Notable changes**
echo
awk "/^## \[Unreleased\]/,/^## \[${PREV_VERSION:3}\]/ {print}" CHANGELOG.md | sed -e '1d' -e '$d'
echo
echo '<!--more-->'
echo
echo **Commits by author**
echo
git shortlog --format="%s@@@%H@@@%h@@@" --grep="maven-release-plugin|update versions in readme.md" --extended-regexp --invert-grep --no-merges $PREV_VERSION..HEAD | perl release_notes_filter.pl ${VERS}
# Update CHANGELOG.md with the new version
NL=$'\n'
if grep -q "$VERS" CHANGELOG.md; then
: # nothing to do here, CHANGELOG has already been updated
else
sed -i -e "s/^## \[Unreleased\]$/## [Unreleased]\\$NL### Changed\\$NL\\$NL### Added\\$NL\\$NL### Fixed\\$NL\\$NL## [${VERS}] (${DATE_YMD})/" CHANGELOG.md
sed -i -e "s/^\[Unreleased\]: /[${VERS}]: /" CHANGELOG.md
sed -i -e "s/$PREV_VERSION\.\.\.HEAD/$PREV_VERSION...REL${VERS}/" CHANGELOG.md
echo "[Unreleased]: https://github.com/pgjdbc/pgjdbc/compare/REL${VERS}...HEAD" >> CHANGELOG.md
fi