-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·89 lines (74 loc) · 1.73 KB
/
release.sh
File metadata and controls
executable file
·89 lines (74 loc) · 1.73 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
set -e
repo_root="$(cd "$(dirname "$0")/.." && pwd)"
cd "$repo_root"
FORCE=false
usage() {
echo "Usage: $0 [options] VERSION"
echo
echo "VERSION:"
echo " major: bump major version number"
echo " minor: bump minor version number"
echo " patch: bump patch version number"
echo
echo "Options:"
echo " -f, --force: force release"
echo " -h, --help: show this help message"
exit 1
}
# parse args
while [ "$#" -gt 0 ]; do
case "$1" in
-f | --force)
FORCE=true
shift
;;
-h | --help)
usage
;;
*)
break
;;
esac
done
# check if version is specified
if [ "$#" -ne 1 ]; then
usage
fi
if [ "$1" != "major" ] && [ "$1" != "minor" ] && [ "$1" != "patch" ]; then
usage
fi
# check if git is clean and force is not enabled
if ! git diff-index --quiet HEAD -- && [ "$FORCE" = false ]; then
echo "Error: git is not clean. Please commit all changes first."
exit 1
fi
if ! command -v uv &> /dev/null; then
echo "Error: uv is not installed. Please install uv from https://docs.astral.sh/uv/"
exit 1
fi
echo "Would bump version:"
uv version --bump "$1" --dry-run
# prompt for confirmation
if [ "$FORCE" = false ]; then
read -p "Do you want to release? [yY] " -n 1 -r
echo
else
REPLY="y"
fi
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
# replace version number
uv version --bump "$1"
new_version=$(uv version --short)
# commit changes
git add pyproject.toml uv.lock
git commit -m "bump version to $new_version"
git tag -a "v$new_version" -m "v$new_version"
# push changes
git push origin main
git push origin "v$new_version"
else
echo "Aborted."
exit 1
fi