App-TestOnTap
view release on metacpan or search on metacpan
author/patch-next-version.pl view on Meta::CPAN
use 5.010_001;
use strict;
use warnings;
$| = 1;
my $msgfile = $ARGV[0] || '';
die("Missing message file\n") unless -f $msgfile;
my $msgfile2 = "$msgfile.tmp.$$";
my $toplevel = qx(git rev-parse --show-toplevel 2>&1);
die("Failed to get toplevel:\n$toplevel") if $?;
chomp($toplevel);
chdir($toplevel) or die("Failed to chdir to $toplevel: $!\n");
my %files =
(
'README.md' => 1,
'extras/Java/TAPGenerator/src/main/java/org/cpan/knth/TAPGenerator.java' => 11,
'lib/App/TestOnTap/_Args._pod' => 9,
'lib/App/TestOnTap/Args.pm' => 10,
'lib/App/TestOnTap/Args.pod' => 9,
'lib/App/TestOnTap/Config.pm' => 6,
'lib/App/TestOnTap/Dispenser.pm' => 6,
'lib/App/TestOnTap/ExecMap.pm' => 6,
'lib/App/TestOnTap/Harness.pm' => 6,
'lib/App/TestOnTap/OrderStrategy.pm' => 6,
'lib/App/TestOnTap/PackInfo.pm' => 6,
'lib/App/TestOnTap/ParallelGroupManager.pm' => 6,
'lib/App/TestOnTap/Preprocess.pm' => 6,
'lib/App/TestOnTap/Scheduler.pm' => 6,
'lib/App/TestOnTap/Util.pm' => 6,
'lib/App/TestOnTap/WorkDirManager.pm' => 6,
'lib/App/TestOnTap.pm' => 8,
'lib/App/TestOnTap.pod' => 10,
'script/testontap' => 6,
);
foreach my $fn (keys(%files))
{
die("Failed to find '$fn' in '$toplevel'\n") unless -f "$toplevel/$fn";
}
# verify we're clean
#
my @status = qx(git status --porcelain --ignored 2>&1);
@status = grep(!m#^!! tmp/$#, @status);
die("Tree not clean:\n@status") if (@status || $?);
# find the current branch:
#
my @br = qx(git symbolic-ref --short HEAD 2>&1);
die("Failed symbref:\n@br") if $?;
chomp(@br);
die("No current branch found") unless @br;
die("Invalid branch: '$br[0]'") unless $br[0] =~ /^(\d+)\.(?:(\d\d\d)_)?xxx$/;
my $mj = $1;
my $min = $2;
my $isdev = defined($min) ? 1 : 0;
system("git fetch --all -q 2>&1");
die("Failed fetch") if $?;
my @tags = qx(git tag -l 2>&1);
die("Failed tags:\n@tags") if $?;
chomp(@tags);
my $tagfilter = $isdev ? qr/^v(${mj}\.${min}_(\d\d\d))$/ : qr/^v(${mj}\.(\d\d\d))$/;
@tags = sort(grep(/$tagfilter/, @tags));
my $lastTag = $tags[-1];
die("???") unless $lastTag =~ /$tagfilter/;
my $currentVersion = sprintf("${mj}.%s%03d", ($isdev ? "${min}_" : ''), $2);
my $currentVersionRE = qr(\Q$currentVersion\E);
my $nextVersion = sprintf("${mj}.%s%03d", ($isdev ? "${min}_" : ''), $2 + 1);
my $nextTag = "v$nextVersion";
print "Next version is '$nextVersion'\n";
foreach my $fn (keys(%files))
{
my $line = $files{$fn};
print "Changing 'version' in $fn...\n";
$fn = "$toplevel/$fn";
my $idx = $line - 1;
my @contents = readAll($fn);
die("The file '$fn' does not have the current version '$currentVersion' in line $line\n") unless $contents[$idx] =~ /$currentVersionRE/;
$contents[$idx] =~ s/$currentVersionRE/$nextVersion/;
writeAll($fn, @contents);
}
my @msg = readAll($msgfile);
my $subj = "Release $nextVersion";
writeAll($msgfile2, $subj, "", @msg);
my @tm = localtime();
my $today = sprintf("%d-%02d-%02d\n", $tm[5] += 1900, $tm[4] + 1, $tm[3]);
my @changes = readAll('Changes');
foreach (@msg)
{
$_ = "\t$_" if $_;
( run in 0.830 second using v1.01-cache-2.11-cpan-39bf76dae61 )