-
Notifications
You must be signed in to change notification settings - Fork 6
/
bump_version.sh
executable file
·59 lines (36 loc) · 1.62 KB
/
bump_version.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
# $ ./bump_version.sh [VERSION]
# Where:
# [VERSION] current version string in "n.n.n" format, just numbers
set -eo pipefail
if [ -z "$1" ]; then
echo "Please pass [VERSION]"
exit 1
fi
# TODO check that no diff is being carried
new_version=$1
# --- Get current version ---
current_version="$(grep -Eo '^__version__.*$' src/flake8_aaa/__about__.py | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"
today=$(date "+%Y/%m/%d")
# TODO check that new version > current version
echo "Current version = '$current_version'"
echo " New version = '$new_version'"
echo " Today = '$today'"
# === Update __about__ ===
sed --in-place "s/__version__ = '$current_version'$/__version__ = '$new_version'/" src/flake8_aaa/__about__.py
echo "*** /src/flake8_aaa/__about__.py updated."
# === Update CHANGELOG ===
# Add new version subtitle after link to latest docs, released today
# underline=$(echo $new_version | sed 's/./-/g')
title="${new_version}_ - ${today}"
underline=${title//?/-}
sed --in-place "/#__unreleased_marker__/ a\ \n${title}\n${underline}" CHANGELOG.rst
# This leaves a single whitespace on the line above the new subtitle, so remove that
sed --in-place "s/^ $//" CHANGELOG.rst
# Update Unreleased link:
sed --in-place "s/^\.\. _Unreleased: .*$/.. _Unreleased: https:\/\/github.com\/jamescooke\/flake8-aaa\/compare\/v${new_version}...HEAD/" CHANGELOG.rst
# Add link for new release after unreleased link:
sed --in-place "/^\.\. _Unreleased: .*$/a .. _${new_version}: https://github.com/jamescooke/flake8-aaa/compare/v${current_version}...v${new_version}" CHANGELOG.rst
echo "*** /CHANGELOG.rst updated."
echo
git diff