-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbump_version.sh
More file actions
51 lines (41 loc) · 905 Bytes
/
bump_version.sh
File metadata and controls
51 lines (41 loc) · 905 Bytes
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
set -e
# 1. Fetch latest tags from remote
git fetch --tags
# 2. Get latest tag
latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)" 2>/dev/null || echo "0.0.0")
echo "Latest tag: $latest_tag"
# 3. Ask for version bump type
echo "Choose version bump type:"
echo "1) patch"
echo "2) minor"
echo "3) major"
read -p "Enter 1, 2, or 3: " choice
# 4. Split version into parts
IFS='.' read -r major minor patch <<< "${latest_tag//v/}"
# 5. Increment version
case $choice in
1)
patch=$((patch + 1))
;;
2)
minor=$((minor + 1))
patch=0
;;
3)
major=$((major + 1))
minor=0
patch=0
;;
*)
echo "Invalid choice"
exit 1
;;
esac
new_tag="v$major.$minor.$patch"
echo "New tag will be: $new_tag"
# 6. Create the tag
git tag $new_tag
# 7. Push the tag to remote
git push origin $new_tag
echo "Tag $new_tag pushed successfully!"