~yerinalexey/dotfiles

ref: a20b9321f36d731891bfadcdd178e7cf1c1e5af7 dotfiles/scripts/rel -rwxr-xr-x 914 bytes
a20b9321Alexey Yerin rel: make unknown type error more descriptive a month ago
                                                                                
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
#!/bin/sh

# Make a release

tag="$(git describe --tags 2>/dev/null | cut -d'-' -f1)"

if [ -z "$tag" ]; then
	printf "No tags\n"
	exit 1
fi

major="$(printf '%s' "$tag" | cut -d'.' -f1)"
minor="$(printf '%s' "$tag" | cut -d'.' -f2)"
patch="$(printf '%s' "$tag" | cut -d'.' -f3)"

case "$1" in
	major)
		major=$(($major+1))
		minor=0
		patch=0
		;;
	minor)
		minor=$(($minor+1))
		patch=0
		;;
	patch)
		patch=$(($patch+1))
		;;
	*)
		printf "Unknown release type '%s'. Expected major, minor or patch\n" "$inc"
		exit 1
		;;
esac

new_tag="$major.$minor.$patch"

shortlog="$(git shortlog "$tag"..master)"
tag_message="$(basename "$PWD") $new_tag

$shortlog"

run_hooks() {
	if [ -f contrib/_incr_version ]; then
		./contrib/_incr_version "$tag" "$new_tag" || return 1
	fi
}

if ! run_hooks; then
	printf "Hook returned non-zero exit code, aborting release\n"
	exit 1
fi

git tag -a -e -m "$tag_message" "$new_tag"