3 use warnings FATAL => 'all';
7 use Getopt::Long qw(:config gnu_getopt);
10 "branch=s" => \(my $branch = 'master'),
11 "changelog=s" => \(my $changelog = 'Changes'),
12 ) or die("Error in command line arguments\n");
14 my $version = shift or die "version required!";
16 my $make = $Config{make};
17 my $null = File::Spec->devnull;
20 if (system("git rev-parse --quiet --verify v$version >$null") == 0) {
21 die "Tag v$version already exists!";
24 for (scalar `"$make" manifest 2>&1 >$null`) {
25 $_ && die "$make manifest changed:\n$_ Go check it and retry";
28 for (scalar `git status`) {
29 /^(?:# )?On branch \Q$branch\E/ || die "Not on $branch. EEEK";
30 /Your branch is behind|Your branch and .*? have diverged/ && die "Not synced with upstream";
33 for (scalar `git diff`) {
34 length && die "Outstanding changes";
37 "%i-%02i-%02i", (gmtime)[5]+1900, (gmtime)[4]+1, (gmtime)[3]
39 my $changes_line = "$version - $ymd\n";
40 my @cached = grep /^\+/, `git diff --cached -U0`;
41 @cached > 0 or die "Please add:\n\n$changes_line\nto $changelog and stage $changelog (git add $changelog)";
42 @cached == 2 or die "All '$changelog' changes must be committed aside from version heading";
43 $cached[0] =~ /^\+\+\+ .\/\Q$changelog\E\n/ or die "$changelog not changed";
44 $cached[1] eq "+$changes_line" or die "$changelog new line should be: \n\n$changes_line ";
46 { no warnings 'exec'; `cpan-upload -h`; }
47 $? and die "cpan-upload not available";