script/librelease.sh: add git push for the release tag
[kai/samba.git] / script / librelease.sh
1 #!/bin/bash
2 # make a release of a Samba library
3
4 GPG_USER='Samba Library Distribution Key <samba-bugs@samba.org>'
5 GPG_KEYID='13084025'
6
7 if [ ! -d ".git" ]; then
8         echo "Run this script from the top-level directory in the"
9         echo "repository"
10         exit 1
11 fi
12
13 if [ $# -lt 1 ]; then
14     echo "Usage: librelease.sh <LIBNAMES>"
15     exit 1
16 fi
17
18 umask 0022
19
20 release_lib() {
21     lib="$1"
22     srcdir="$2"
23
24     pushd $srcdir
25
26     echo "Releasing library $lib"
27
28     echo "building release tarball"
29     tgzname=$(make dist 2>&1 | grep ^Created | cut -d' ' -f2)
30     [ -f "$tgzname" ] || {
31         echo "Failed to create tarball"
32         exit 1
33     }
34     tarname=$(basename $tgzname .gz)
35     echo "Tarball: $tarname"
36     gunzip -f $tgzname || exit 1
37     [ -f "$tarname" ] || {
38         echo "Failed to decompress tarball $tarname"
39         exit 1
40     }
41
42     tagname=$(basename $tarname .tar)
43     echo "tagging as $tagname"
44     git tag -u $GPG_KEYID -s "$tagname" -m "$lib: tag release $tagname" || {
45         exit 1
46     }
47
48     echo "signing"
49     rm -f "$tarname.asc"
50     gpg -u "$GPG_USER" --detach-sign --armor $tarname || {
51         exit 1
52     }
53     [ -f "$tarname.asc" ] || {
54         echo "Failed to create signature $tarname.asc"
55         exit 1
56     }
57     echo "compressing"
58     gzip -f -9 $tarname
59     [ -f "$tgzname" ] || {
60         echo "Failed to compress $tgzname"
61         exit 1
62     }
63
64     echo "Push git tag $tagname"
65     git push ssh://git.samba.org/data/git/samba.git refs/tags/$tagname:refs/tags/$tagname || {
66         exit 1
67     }
68
69     echo "Transferring for FTP"
70     rsync -Pav $tarname.asc $tgzname master.samba.org:~ftp/pub/$lib/ || {
71         exit 1
72     }
73     rsync master.samba.org:~ftp/pub/$lib/$tarname.*
74
75     popd
76 }
77
78 for lib in $*; do
79     case $lib in
80         talloc | tdb | tevent)
81             release_lib $lib "lib/$lib"
82             ;;
83         ldb)
84             release_lib $lib "source4/lib/$lib"
85             ;;
86         *)
87             echo "Unknown library $lib"
88             exit 1
89     esac
90 done