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 70 71 72 73 74
|
#!/usr/bin/perl
use warnings;
use strict;
use File::Path;
use LWP::Simple;
use ExtUtils::MakeMaker qw(prompt);
my $version = shift @ARGV or die "Usage: release.pl version";
my $workdir = "$ENV{HOME}/pmsetup";
my $checkout = "String-Diff-$version";
chdir $workdir;
if (-e $checkout) {
die "$workdir/$checkout exists. Remove it first";
}
system("svk co //mirror/public/String-Diff/trunk $checkout");
sleep(2);
if (-e $checkout) {
chdir $checkout;
rewrite_version("lib/String/Diff.pm", $version);
system("perl Makefile.PL --skip");
system("make manifest");
check_version("Changes", $version);
if (!system("make disttest")) {
system("svk ci -m 'packaging $version'");
system("svk cp -m 'tag release $version' //mirror/public/String-Diff/trunk //mirror/public/String-Diff/tags/release-$version");
system("make dist");
if (prompt("upload to CPAN?: [yN]", 'n') =~ /[yY]/) {
system("cpan-upload -verbose String-Diff-$version.tar.gz");
} else {
rename "String-Diff-$version.tar.gz", "../String-Diff-$version.tar.gz";
}
} else {
warn "make disttest failed. Don't upload";
}
chdir "..";
system("svk co --detach $checkout");
}
rmtree("$workdir/$checkout");
sub rewrite_version {
my($file, $version) = @_;
open my $fh, $file or die "$file: $!";
my $content = join '', <$fh>;
close $fh;
$content =~ s/^our \$VERSION = .*?;$/our \$VERSION = '$version';/m;
open my $out, ">", "lib/String/Diff.pm";
print $out $content;
close $out;
}
sub check_version {
my($file, $version) = @_;
open my $fh, $file or die "$file: $!";
while (<$fh>) {
/^\Q$version\E / and return 1;
}
die "$file doesn't contain log for $version";
}
|