summaryrefslogtreecommitdiff
path: root/make_a_release.sh
blob: dca2ec3cfc3d2d8052a9cc40053372bd07b0f164 (plain)
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
#!/bin/sh -uef

# A small helper script taken from mtd-utils to generate a release tar ball.

fatal() {
	printf "Error: %s\n" "$1" >&2
	exit 1
}

usage() {
	cat <<EOF
Usage: ${0##*/} <new_ver> <outdir>

<new_ver>  - mtd utils version to create in X.Y[.Z[-rcX]] format
<outdir>   - the output directory where to store the tarball
EOF
	exit 0
}

[ $# -eq 0 ] && usage
[ $# -eq 2 ] || fatal "Insufficient or too many argumetns"

new_ver="$1"
outdir="$2"

release_name="init-$new_ver"
tag_name="v$new_ver"

# Make sure the input is sane and the makefile contains sensible version
VER_REGEX="[0-9]\+.[0-9]\+\(.[0-9]\+\)\?\(-rc[0-9]\+\)\?"

echo "$new_ver" | grep -q -x "$VER_REGEX" ||
        fatal "please, provide new version in X.Y[.Z][-rcX] format"

grep -q -x "m4_define(\[RELEASE\], $VER_REGEX)" configure.ac ||
        fatal "configure.ac does not contain a valid version string"

# Make sure the git index is up-to-date
[ -z "$(git status --porcelain)" ] || fatal "Git index is not up-to-date"

# Make sure the tag does not exist
[ -z "$(git tag -l "$tag_name")" ] || fatal "Tag $tag_name already exists"

# Change the version in the configure.ac
sed -i -e "s/^m4_define(\[RELEASE\], $VER_REGEX)/m4_define([RELEASE], $new_ver)/" configure.ac

# And commit the change
git commit -m "Release $release_name" configure.ac

# Create new tag
echo "Signing tag $tag_name"
git tag -m "$release_name" "$tag_name"

# Prepare tarball
./autogen.sh
./configure
make distcheck
mkdir -p "$outdir"
mv "$release_name.tar.xz" "$outdir"