-
Notifications
You must be signed in to change notification settings - Fork 2
/
bump_version.sh
executable file
·71 lines (56 loc) · 1.74 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
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -e
# server version
if [[ -z $1 ]]
then
>&2 echo 'Error: no version specified'
exit 1
fi
# next server version
if [[ -z $2 ]]
then
>&2 echo 'Error: no next version specified'
exit 1
fi
# check the repo is clean
if [[ $(git status --porcelain) ]]
then
>&2 echo 'Error: the repository is not clean, commit unstaged files'
exit 1
fi
version_number=$1
dev_version_number=$2-dev
version_date=$(date -I -u)
version_year=$(date +%Y -u)
# patch version and date in version file
version_file=src/dakara_player/version.py
sed -i \
-e "s/^__version__ = .*$/__version__ = \"$version_number\"/" \
-e "s/^__date__ = .*$/__date__ = \"$version_date\"/" \
$version_file
# change version in changelog
changelog_file=CHANGELOG.md
sed -i "/^## Unreleased$/a \\
\\
## $version_number - $version_date" $changelog_file
# change version in appveyor config file
appveyor_file=.appveyor.yml
sed -i "s/^version: .*-{build}$/version: $version_number-{build}/" $appveyor_file
# change year in license file
license_file=LICENSE
sed -i -e "s/(c) [0-9]\{4\}/(c) $version_year/" $license_file
# create commit and tag
git add $version_file $changelog_file $appveyor_file $license_file
git commit -m "Version $version_number" --no-verify
git tag "$version_number"
# say something
echo "Version bumped to $version_number"
# patch dev version in version file
sed -i "s/^__version__ = .*$/__version__ = \"$dev_version_number\"/" $version_file
# change version in appveyor config file
sed -i "s/^version: .*-{build}$/version: $dev_version_number-{build}/" $appveyor_file
# create commit
git add $version_file $appveyor_file
git commit -m "Dev version $dev_version_number" --no-verify
# say something
echo "Updated to dev version $dev_version_number"