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 `git status`) {
25 /^(?:# )?On branch \Q$branch\E/ || die "Not on $branch. EEEK";
26 /Your branch is behind|Your branch and .*? have diverged/ && die "Not synced with upstream";
29 for (scalar `git diff`) {
30 length && die "Outstanding changes";
33 "%i-%02i-%02i", (gmtime)[5]+1900, (gmtime)[4]+1, (gmtime)[3]
35 my $changes_line = "$version - $ymd\n";
36 my @cached = grep /^\+/, `git diff --cached -U0`;
37 @cached > 0 or die "Please add:\n\n$changes_line\nto $changelog and stage $changelog (git add $changelog)";
38 @cached == 2 or die "All '$changelog' changes must be committed aside from version heading";
39 $cached[0] =~ /^\+\+\+ .\/\Q$changelog\E\n/ or die "$changelog not changed";
40 $cached[1] eq "+$changes_line" or die "$changelog new line should be: \n\n$changes_line ";
42 { no warnings 'exec'; `cpan-upload -h`; }
43 $? and die "cpan-upload not available";