-
Notifications
You must be signed in to change notification settings - Fork 1
/
bumpversion.sh
executable file
·31 lines (28 loc) · 1.19 KB
/
bumpversion.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
#!/bin/bash
set -e
PUBDIR="/home/tom/Documents/dev/your_budget"
# Find and increment the version and build number.
if [ $# -eq 0 ]
then
echo "Updating build number"
perl -i -pe 's/^(version:\s+)(\d+)(\.)(\d+)(\.)(\d+)(\+)(\d+)$/$1.$2.$3.$4.$5.$6.$7.($8+1)/e' "$PUBDIR/pubspec.yaml"
elif [[ $# -eq 1 && "$1" == "--major" ]]
then
echo "Updating major version number"
perl -i -pe 's/^(version:\s+)(\d+)(\.)(\d+)(\.)(\d+)(\+)(\d+)$/$1.($2+1).$3.(0).$5.(0).$7.($8+1)/e' "$PUBDIR/pubspec.yaml"
elif [[ $# -eq 1 && "$1" == "--minor" ]]
then
echo "Updating minor version number"
perl -i -pe 's/^(version:\s+)(\d+)(\.)(\d+)(\.)(\d+)(\+)(\d+)$/$1.$2.$3.($4+1).$5.(0).$7.($8+1)/e' "$PUBDIR/pubspec.yaml"
elif [[ $# -eq 1 && "$1" == "--patch" ]]
then
echo "Updating patch version number"
perl -i -pe 's/^(version:\s+)(\d+)(\.)(\d+)(\.)(\d+)(\+)(\d+)$/$1.$2.$3.$4.$5.($6+1).$7.($8+1)/e' "$PUBDIR/pubspec.yaml"
else
exit 1
fi
# Commit and tag this change.
version=`grep 'version: ' "$PUBDIR/pubspec.yaml" | sed 's/version: //'`
echo "$version" > "$PUBDIR/version.txt"
git commit -m "Bump version to $version" "$PUBDIR/pubspec.yaml" "$PUBDIR/version.txt"
git tag "$version"