summaryrefslogtreecommitdiffstats
path: root/make_release
blob: 54c43f0b955697f24b2c243846caeafb71e418fd (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
60
61
62
63
64
65
66
67
68
69
#!/bin/sh

proj="iperf"

if [ "x$2" != "x" ]; then
tag=$2
else
tag=`awk '/IPERF_VERSION / {
  gsub(/"/, "", $3);
  print $3 }' src/version.h`
fi

dirname=`echo "$tag $proj" | awk '{
  gsub(/-ALPHA/, "a", $1);
  gsub(/-BETA/, "b", $1);
  gsub(/-RELEASE/, "", $1);
  print $2"-"$1 }'`

echo tag $tag
echo dirname $dirname

do_tag ()
{
    git tag -s -m "tagging $tag" "$tag"
}

do_tar ()
{
    tarball=${dirname}.tar.gz
    rm -f "${tarball}"
    git archive --format=tar --prefix "${dirname}/" "${tag}" | gzip -9 > "${tarball}"

    # Compute SHA256 hash
    case `uname -s` in
	FreeBSD) sha=sha256 ;;
	Linux) sha=sha256sum ;;
	Darwin) sha="shasum -a 256" ;;
	*) sha=echo ;;
    esac
    ${sha} "${tarball}" | tee "${tarball}.sha256"
}

usage ()
{
    cat <<EOF
$0: tag|tar

   tag  -- create a tag
   tar  -- create a tarball from a tag

General use is to do:

./$0 tag
./$0 tar

An optional argument may be specified to both the tag and tar
subcommands to explicitly specify a tag string.  If not specified, the
contents of src/version.h are used.

EOF
}

case $1 in
    tag) do_tag ;;
    tar) do_tar ;;
    *) echo "unknown command: $1"; usage ;;
esac

exit