File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ # MISE description="Create next semantic git tag"
6+ # USAGE arg "[bump]" help="Version bump level" default="patch" {
7+ # USAGE choices "major" "minor" "patch"
8+ # USAGE }
9+
10+ latest_tag=$( git describe --tags --abbrev=0 --match ' v[0-9]*' 2> /dev/null || true)
11+ if [ -z " $latest_tag " ]; then
12+ latest_tag=" v0.0.0"
13+ fi
14+
15+ version=${latest_tag# v}
16+ IFS=. read -r major minor patch <<< " $version"
17+
18+ case " ${usage_bump?} " in
19+ major)
20+ major=$(( major + 1 ))
21+ minor=0
22+ patch=0
23+ ;;
24+ minor)
25+ minor=$(( minor + 1 ))
26+ patch=0
27+ ;;
28+ patch)
29+ patch=$(( patch + 1 ))
30+ ;;
31+ esac
32+
33+ new_tag=" v${major} .${minor} .${patch} "
34+
35+ if git rev-parse -q --verify " refs/tags/$new_tag " > /dev/null; then
36+ echo " error: $new_tag tag already exists"
37+ exit 1
38+ fi
39+
40+ git tag -a " $new_tag " -m " Release $new_tag "
41+
42+ echo " created tag: $new_tag "
43+ echo " push with: git push origin $new_tag "
You can’t perform that action at this time.
0 commit comments