-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·51 lines (42 loc) · 1.27 KB
/
release.sh
File metadata and controls
executable file
·51 lines (42 loc) · 1.27 KB
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
#!/bin/bash
# Updates release version, makes a commit, and git tag.
set -euo pipefail
usage() {
echo "Usage: $0 [-h] <new-version>"
echo " -h Display this help message"
echo " new-version New version to update package to"
exit $1
}
# new version
newVersion="${1:-}"
if [[ -z "$newVersion" ]]; then
echo "Please provide a version number"
usage 1
fi
# display help if requested
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" || "${1:-}" == "-help" || "${1:-}" == "help" ]]; then
usage 0
fi
# get current version from setup.py
currentVersion=$(grep -oP 'version="\K[^"]+' setup.py)
# modify files with the version in it
operatingSystem=$(uname -s)
if [[ "$operatingSystem" == "Darwin" ]]; then
sed -i '.old' "s+$currentVersion+$newVersion+g" README.md setup.py
rm README.md.old setup.py.old
elif [[ "$operatingSystem" == "Linux" ]]; then
sed -i "s+$currentVersion+$newVersion+g" README.md setup.py
else
echo "Unsupported operating system"
exit 1
fi
# commit and tag
git add README.md
git add setup.py
git commit -m "chore(release): v$newVersion"
echo "Creating git tag v$newVersion"
git tag "v$newVersion"
# print instructions
echo "Run the following command to push the changes:"
echo "git push origin main"
echo "git push origin tag v$newVersion"