-
Notifications
You must be signed in to change notification settings - Fork 18
/
bump-version.sh
executable file
·43 lines (33 loc) · 1.15 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
#!/bin/bash
# This script is designed to bump the version in all notebooks and
# then rerun them to ensure the output hasn't changed.
# Note that it's very primitive and will simply search for the current
# version string so it may change things it's not supposed to.
VERSION=1.21.0
BUMP_TYPE=minor
if [ $# -eq 1 ]; then
BUMP_TYPE=$1
fi
if [ $# -gt 1 ]; then
>&2 echo "usage: $0 [<bump_type>]"
exit 1
fi
if ! git diff --exit-code &> /dev/null; then
>&2 echo "Commit all changes before proceeding."
exit 1
fi
escaped_version=$(echo $VERSION | sed 's/\./\\\./g')
new_version=$(./semver bump $BUMP_TYPE $VERSION 2> /dev/null)
if [ $? -ne 0 ]; then
>&2 echo "Error bumping version. Bump type should be one of major, minor, or patch."
exit 1
fi
echo "Changing from version $VERSION to $new_version..."
sed -i "s/$escaped_version/$new_version/g" *.ipynb bump-version.sh
echo "Rerunning notebooks..."
if ! jupyter nbconvert --to notebook --execute --inplace --clear-output *.ipynb 2> /dev/null; then
>&2 echo "Error rerunning notebooks."
exit 1
fi
git diff --exit-code *.ipynb;
echo "Version changed successfully. Review output above before committing."