File tree Expand file tree Collapse file tree 1 file changed +72
-0
lines changed
Expand file tree Collapse file tree 1 file changed +72
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Default increment type
4+ increment_type=" patch"
5+
6+ # Parse command line arguments
7+ while [[ $# -gt 0 ]]; do
8+ case $1 in
9+ --major|-M)
10+ increment_type=" major"
11+ shift
12+ ;;
13+ --minor|-m)
14+ increment_type=" minor"
15+ shift
16+ ;;
17+ --patch|-p)
18+ increment_type=" patch"
19+ shift
20+ ;;
21+ --help|-h)
22+ echo " Usage: $0 [--major|-M] [--minor|-m] [--patch|-p]"
23+ echo " --major, -M: Increment major version (x.0.0)"
24+ echo " --minor, -m: Increment minor version (x.y.0)"
25+ echo " --patch, -p: Increment patch version (x.y.z) [default]"
26+ exit 0
27+ ;;
28+ * )
29+ echo " Unknown option $1 "
30+ exit 1
31+ ;;
32+ esac
33+ done
34+
35+ # Get current tag
36+ current_tag=$( git describe --tags --abbrev=0 2> /dev/null)
37+ if [ $? -ne 0 ]; then
38+ echo " No tags found. Creating initial tag v1.0.0"
39+ new_tag=" v1.0.0"
40+ else
41+ # Remove 'v' prefix and split into parts
42+ version=${current_tag# v}
43+ IFS=' .' read -ra VERSION_PARTS <<< " $version"
44+
45+ # Increment based on type
46+ case $increment_type in
47+ " major" )
48+ (( VERSION_PARTS[0 ]++ ))
49+ VERSION_PARTS[1]=0
50+ VERSION_PARTS[2]=0
51+ ;;
52+ " minor" )
53+ (( VERSION_PARTS[1 ]++ ))
54+ VERSION_PARTS[2]=0
55+ ;;
56+ " patch" )
57+ (( VERSION_PARTS[2 ]++ ))
58+ ;;
59+ esac
60+
61+ new_tag=" v${VERSION_PARTS[0]} .${VERSION_PARTS[1]} .${VERSION_PARTS[2]} "
62+ fi
63+
64+ echo " Current tag: $current_tag "
65+ echo " New tag: $new_tag "
66+ echo " Increment type: $increment_type "
67+
68+ # Create and push the new tag
69+ git tag -a $new_tag -m " Release $new_tag ($increment_type increment)"
70+ git push origin $new_tag
71+
72+ echo " Created and pushed tag: $new_tag "
You can’t perform that action at this time.
0 commit comments