]> Pileus Git - ~andy/fetchmail/blob - dist-tools/makerelease.pl
Sign .xz; upload to sf.net; upload .xz to local site.
[~andy/fetchmail] / dist-tools / makerelease.pl
1 #!/usr/bin/perl -w
2 #
3 # Make a fetchmail release.
4 # Dumps a release notice and diffs as a MIME multipart message 
5 # in RELEASE_NOTES
6 #
7
8 my $project = "fetchmail";
9 my $website = "http://developer.berlios.de/projects/$project";
10 my $mailfrom = "<$project-devel\@lists.berlios.de> (Fetchmail Development Team)";
11 my $distsufx =  '.tar.bz2';
12 my $xzsufx =    '.tar.xz';
13
14 # ---------------------------------------------------------------------
15
16 use POSIX qw(strftime);
17 use Getopt::Long;
18 use strict vars;
19
20 # check environment
21 (-r "NEWS" and -r "fetchmail.c" and -r "configure.ac") or die "Please cd to the top-level source directory!";
22 die "Need GNU sort!" unless `sort --version | head -n1` =~ /GNU/;
23 system("lftp --version >/dev/null 2>&1") and die "lftp not found!";
24
25 # parse options
26 my $diffs = 0;
27 my $verbose = 0;
28 my $help = 0;
29 my $null = ">/dev/null";
30 my $errnull = "2>/dev/null";
31
32 sub usage($$) {
33     my ($own, $rc) = @_;
34
35     print STDERR "Usage: $_[0] [--verbose,-v] [--help,-h,-?]\n";
36     exit($_[1]);
37 }
38
39 sub makerelnotes($$) {
40     my ($infile, $outfile) = @_;
41     open(F, "<$infile") or die "cannot read $infile: $!";
42     open(G, ">$outfile") or die "cannot write to $outfile: $!";
43     my $ctr = 0;
44     while(<F>) {
45         $ctr++ if /^fetchmail-/;
46         print G if $ctr == 1;
47     }
48     close F or die "cannot read $infile: $!";
49     close G or die "cannot write to $outfile: $!";
50 }
51
52 GetOptions("diffs|d" => \$diffs, "verbose|v" => \$verbose, "help|h|?" => \$help)
53     or usage($0, 1);
54
55 usage($0, 0) if $help;
56
57 die "$0 does not yet work with --diffs - needs to be updated for Git first!" if $diffs;
58
59 if ($verbose) {
60     $null = "";
61 }
62
63 my $tmp = $ENV{TMPDIR} || $ENV{TMP} || $ENV{TEMP} || "/tmp";
64
65 # extract version from source
66 my $version =`grep 'AC_INIT' configure.ac`;
67 $version =~ /AC_INIT\([^,]*,\[?([0-9.rc-]+)\]?\,.*\)/;
68 $version = $1;
69 die "cannot determine version" unless defined $1;
70 my $tag = "RELEASE_$version";
71 $tag =~ tr/./-/;
72
73 # extract existing tags
74 my @versions;
75 open(ID, "git tag | sort -t- -k1,1 -k2,2n -k3,3n |") || die "cannot run git tag: $!\naborting";
76 while (<ID>) {
77         chomp;
78         if (m{^(RELEASE_.*)$}) {
79                 unshift(@versions, $1);
80         }
81 }
82 close ID || die "git tag   failed, aborting";
83
84 my $oldtag; my $oldver;
85 if ($versions[0] eq $tag) {
86         $tag = $versions[0];
87         $oldtag = $versions[1];
88 } else {
89         $tag = '<workfile>';
90         $oldtag = $versions[0];
91 }
92
93 my $pwd = `pwd`; chomp $pwd;
94
95 $ENV{PATH} .= ":$pwd/dist-tools:$pwd/dist-tools/shipper";
96
97 print "Building $version release, tag $tag, previous tag $oldtag\n";
98
99 if (-d "autom4te.cache") {
100         system("rm -rf autom4te.cache")
101                 and die "Failure in removing autom4te.cache";
102 }
103
104 printf "### autoreconf\n";
105
106 if (system("autoreconf -ifs" . ($verbose ? 'v' : ''))) {
107         die("Failure in regenerating autoconf files\n");
108 }
109
110 print "### configure\n";
111
112 if (system("mkdir -p autobuild && cd autobuild " 
113         . " && ../configure -C --silent --with-ssl")) { die("Configuration failure\n"); }
114
115 print "### Test-building the software...\n";
116 if (system("cd autobuild && make -s clean"
117         . " && make " . ($verbose ? '' : '-s') . " check distcheck")) {
118         die("Compilation failure\n");
119 }
120
121 open(REPORT, ">$tmp/$project.PREAMBLE.$$");
122
123 print REPORT <<EOF;
124 From: $mailfrom
125 Subject: The $version release of $project is available
126
127 The $version release of $project is now available at the usual locations,
128 including <$website>.
129
130 The source archive is available at:
131 <$website/$project-$version$distsufx>
132
133 Here are the release notes:
134
135 EOF
136
137 # Extract the current notes
138 open(NEWS, "NEWS");
139 while (<NEWS>) {
140         if (/^$project/) {
141                 print REPORT $_;
142                 last;
143         }
144 }
145 while (<NEWS>) {
146         if (/^$project/) {
147                 last;
148         }
149         print REPORT $_;
150 }
151
152 $oldver = $oldtag;
153 $oldver =~ tr/-/./;
154 $oldver =~ s/^RELEASE_//;
155
156 if ($diffs) {
157         print REPORT "Diffs from the previous ($oldver) release follow as a MIME attachment."
158 } else {
159         print REPORT "By popular demand, diffs from the previous release have been omitted."
160 }
161
162 close(NEWS);
163
164 close(REPORT);
165
166 if ($diffs) {
167         if ($tag eq '<workfile>') {
168                 system("svn diff -r$oldtag        $errnull >$tmp/$project.DIFFS.$$");
169         } else {
170                 system("svn diff -r$oldtag -r$tag $errnull >$tmp/$project.DIFFS.$$");
171         }
172         print "Diff size:";
173         system("wc <$tmp/$project.DIFFS.$$");
174
175         system "metasend -b"
176         ." -D '$project-$tag announcement' -m 'text/plain' -e 7bit -f $tmp/$project.PREAMBLE.$$"
177         ." -n -D 'diff between $oldver and $version' -m 'text/plain' -e 7bit -f $tmp/$project.DIFFS.$$"
178         ." -o ANNOUNCE.EMAIL";
179 } else {
180         system("mv", "$tmp/$project.PREAMBLE.$$", "ANNOUNCE.EMAIL");
181 }
182
183 #unlink("$tmp/$project.PREAMBLE.$$");
184 unlink("$tmp/$project.DIFFS.$$");
185
186 print "### Signing tarballs...\n";
187 system("cd autobuild && gpg -ba --sign $project-$version$distsufx");
188 system("cd autobuild && gpg -ba --sign $project-$version$xzsufx");
189
190 print "### Extracting release notes...\n";
191 makerelnotes('NEWS', 'autobuild/README');
192
193 print "### Uploading\n";
194 print "=== local\n";
195
196 system("cp", "autobuild/$project-$version$xzsufx", "autobuild/$project-$version$xzsufx.asc", "$ENV{HOME}/public_html/fetchmail/") and die "Cannot upload to \$HOME/public_html/fetchmail/: $!";
197
198 print "=== berlios\n";
199
200 system("lftp -e \"lcd autobuild ; mput $project-$version$distsufx $project-$version$distsufx.asc ; quit\" ftp.berlios.de:/incoming/") and warn "Upload to berlios failed: $!";
201
202 print "=== sourceforge \n";
203 system("rsync -acvHP autobuild/$project-$version$xzsufx autobuild/$project-$version$xzsufx.asc autobuild/README m-a\@frs.sourceforge.net:/home/frs/project/fetchmail/branch_6.3/");
204 unlink 'autobuild/README' or die "cannot unlink autobuild/README: $!";
205
206 print "=== Done - please review final tasks\n";
207
208 system("cat RELEASE-INSTRUCTIONS");
209
210 # makerelease ends here