Commit | Line | Data |
be032607 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings FATAL => 'all'; |
4 | use Config; |
5 | use File::Spec; |
6 | use File::Find; |
190976f8 |
7 | use Getopt::Long qw(:config gnu_getopt); |
be032607 |
8 | |
190976f8 |
9 | GetOptions( |
10 | "branch=s" => \(my $branch = 'master'), |
9b920c5c |
11 | "changelog=s" => \(my $changelog = 'Changes'), |
190976f8 |
12 | ) or die("Error in command line arguments\n"); |
13 | |
14 | my $version = shift or die "version required!"; |
be032607 |
15 | |
16 | my $make = $Config{make}; |
17 | my $null = File::Spec->devnull; |
18 | |
19 | system("git fetch"); |
20 | if (system("git rev-parse --quiet --verify v$version >$null") == 0) { |
21 | die "Tag v$version already exists!"; |
22 | } |
23 | |
be032607 |
24 | for (scalar `"$make" manifest 2>&1 >$null`) { |
25 | $_ && die "$make manifest changed:\n$_ Go check it and retry"; |
26 | } |
27 | |
28 | for (scalar `git status`) { |
190976f8 |
29 | /^(?:# )?On branch \Q$branch\E/ || die "Not on $branch. EEEK"; |
be032607 |
30 | /Your branch is behind|Your branch and .*? have diverged/ && die "Not synced with upstream"; |
31 | } |
32 | |
33 | for (scalar `git diff`) { |
34 | length && die "Outstanding changes"; |
35 | } |
36 | my $ymd = sprintf( |
37 | "%i-%02i-%02i", (gmtime)[5]+1900, (gmtime)[4]+1, (gmtime)[3] |
38 | ); |
39 | my $changes_line = "$version - $ymd\n"; |
40 | my @cached = grep /^\+/, `git diff --cached -U0`; |
9b920c5c |
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 "; |
be032607 |
45 | |
46 | { no warnings 'exec'; `cpan-upload -h`; } |
47 | $? and die "cpan-upload not available"; |