-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrelease.sh
executable file
·65 lines (54 loc) · 1.36 KB
/
release.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
#!/usr/bin/env bash
# This script perform first steps of release.
# Update version of package, create tag and push it to upstream.
# Usage: ./release.sh [new_version]
set -e
check_version_format(){
echo "INFO: Check the format of the version."
if ! echo "$1" | grep -q -E '^[0-9]{1,}.[0-9]{1,}.[0-9]{1,}$'; then
echo "ERROR: Bad version format!"
exit 1
fi
}
check_uncommitted_changes(){
echo "INFO: Check uncommitted changes."
if git status --porcelain=v1 | grep -q '^\(.M\|M.\)'; then
echo "ERROR: Not commited changes!"
exit 1
fi
}
update_version(){
echo "INFO: Update version."
new_version=$1
old_version=$(python3 setup.py --version)
sed -i "s/$old_version/$new_version/g" "setup.py"
}
commit_new_version(){
echo "INFO: Commit new version."
version=$1
git add setup.py
git commit -m "${version}"
}
create_tag(){
echo "INFO: Create tag."
version=$1
git tag "v${version}" HEAD
}
push_changes(){
echo "INFO: Push changes."
git push upstream main
git push upstream --tags
}
if [ "$1" = "" ]; then
echo "ERROR: Missing version parameter!"
exit 1
fi
new_version=$1
check_version_format "$new_version"
check_uncommitted_changes
update_version "$new_version"
commit_new_version "$new_version"
create_tag "$new_version"
push_changes
echo "INFO: Done"
exit 0