4 use warnings FATAL => 'all';
6 use ExtUtils::MakeMaker ();
12 our $VERSION = '0.001000';
13 $VERSION = eval $VERSION;
15 my $MM_VER = eval $ExtUtils::MakeMaker::VERSION;
18 author manifest_include readme_generator run_preflight
23 warnings->import(FATAL => 'all');
24 shift->export_to_level(1,@_);
43 '' => qr{Changes|MANIFEST|README|META\.yml},
44 'maint' => qr{[^.].*},
47 sub manifest_include {
51 my $readme_generator = <<'README';
52 pod2text $(VERSION_FROM) >$(DISTVNAME)/README
53 $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) ../Distar/helpers/add-readme-to-manifest
55 sub readme_generator {
56 $readme_generator = shift;
59 sub write_manifest_skip {
60 my @files = @Manifest;
62 while (my ($dir, $spec) = splice(@files, 0, 2)) {
63 my $re = ($dir ? $dir.'/' : '').
64 ((ref($spec) eq 'Regexp')
68 # print ref as well as stringification in case of overload ""
69 : die "spec must be string or regexp, was: ${spec} (${\ref $spec})");
72 my $final = '^(?!'.join('|', map "${_}\$", @parts).')';
73 open my $skip, '>', 'MANIFEST.SKIP'
74 or die "can't open MANIFEST.SKIP: $!";
75 print $skip "${final}\n";
81 my $version = $ARGV[0];
83 my $make = $Config{make};
84 my $null = File::Spec->devnull;
87 if (system("git rev-parse --quiet --verify v$version >$null") == 0) {
88 die "Tag v$version already exists!";
92 File::Find::find({ no_chdir => 1, wanted => sub {
95 my $file_version = MM->parse_version($_);
96 die "Module $_ version $file_version doesn't match dist version $version"
97 unless $file_version eq 'undef' || $file_version eq $version;
100 for (scalar `"$make" manifest 2>&1 >$null`) {
101 $_ && die "$make manifest changed:\n$_ Go check it and retry";
104 for (scalar `git status`) {
105 /^(?:# )?On branch master/ || die "Not on master. EEEK";
106 /Your branch is behind|Your branch and .*? have diverged/ && die "Not synced with upstream";
109 for (scalar `git diff`) {
110 length && die "Outstanding changes";
113 "%i-%02i-%02i", (gmtime)[5]+1900, (gmtime)[4]+1, (gmtime)[3]
115 my $changes_line = "$version - $ymd\n";
116 my @cached = grep /^\+/, `git diff --cached -U0`;
117 @cached > 0 or die "Please add:\n\n$changes_line\nto Changes stage Changes (git add Changes)";
118 @cached == 2 or die "Pre-commit Changes not just Changes line";
119 $cached[0] =~ /^\+\+\+ .\/Changes\n/ or die "Changes not changed";
120 $cached[1] eq "+$changes_line" or die "Changes new line should be: \n\n$changes_line ";
122 { no warnings 'exec'; `cpan-upload -h`; }
123 $? and die "cpan-upload not available";
128 our @ISA = @ExtUtils::MM::ISA;
129 @ExtUtils::MM::ISA = (__PACKAGE__);
132 my ($class, $args) = @_;
133 return $class->SUPER::new({
135 MIN_PERL_VERSION => '5.006',
136 AUTHOR => ($MM_VER >= 6.5702 ? $Distar::Author : $Distar::Author->[0]),
138 ABSTRACT_FROM => $args->{VERSION_FROM},
139 test => { TESTS => ($args->{test}{TESTS}||'t/*.t').' xt/*.t xt/*/*.t' },
145 my $dist_test = $self->SUPER::dist_test(@_) . <<'END'
147 # --- Distar section:
149 perl -IDistar/lib -MDistar -erun_preflight $(VERSION)
153 $(MAKE) $(DISTVNAME).tar$(SUFFIX)
154 git commit -a -m "Release commit for $(VERSION)"
155 git tag v$(VERSION) -m "release v$(VERSION)"
156 cpan-upload $(DISTVNAME).tar$(SUFFIX)
157 git push origin v$(VERSION) HEAD
159 readmefile: create_distdir
161 . $readme_generator . <<'END';
162 disttest: distmanicheck
163 distmanicheck: create_distdir
164 cd $(DISTVNAME) && $(ABSPERLRUN) "-MExtUtils::Manifest=manicheck" -e "exit manicheck"
167 if (open my $fh, '<', 'maint/Makefile.include') {
168 $dist_test .= do { local $/; <$fh> };
175 write_manifest_skip() unless $Ran_Preflight