5 use ExtUtils::MakeMaker ();
11 our $VERSION = '0.001000';
12 $VERSION = eval $VERSION;
15 author manifest_include run_preflight
20 shift->export_to_level(1,@_);
23 sub author { our $Author = shift }
34 '' => qr{Changes|MANIFEST|README|META\.yml},
35 'maint' => qr{[^.].*},
38 sub manifest_include {
42 sub write_manifest_skip {
43 my @files = @Manifest;
45 while (my ($dir, $spec) = splice(@files, 0, 2)) {
46 my $re = ($dir ? $dir.'/' : '').
47 ((ref($spec) eq 'Regexp')
51 # print ref as well as stringification in case of overload ""
52 : die "spec must be string or regexp, was: ${spec} (${\ref $spec})");
55 my $final = '^(?!'.join('|', map "${_}\$", @parts).')';
56 open my $skip, '>', 'MANIFEST.SKIP'
57 or die "can't open MANIFEST.SKIP: $!";
58 print $skip "${final}\n";
64 my $version = $ARGV[0];
68 my $make = $Config{make};
69 my $null = File::Spec->devnull;
72 File::Find::find({ no_chdir => 1, wanted => sub {
75 my $file_version = MM->parse_version($_);
76 die "Module $_ version $file_version doesn't match dist version $version"
77 unless $file_version eq 'undef' || $file_version eq $version;
80 for (scalar `"$make" manifest 2>&1 >$null`) {
81 $_ && die "$make manifest changed:\n$_ Go check it and retry";
84 for (scalar `git status`) {
85 /^# On branch master/ || die "Not on master. EEEK";
86 /Your branch is behind|Your branch and .*? have diverged/ && die "Not synced with upstream";
89 for (scalar `git diff`) {
90 length && die "Outstanding changes";
93 "%i-%02i-%02i", (localtime)[5]+1900, (localtime)[4]+1, (localtime)[3]
95 my $changes_line = "$version $ymd\n";
96 my @cached = grep /^\+/, `git diff --cached -U0`;
97 @cached > 0 or die "Please add:\n\n$changes_line\nto Changes stage Changes (git add Changes)";
98 @cached == 2 or die "Pre-commit Changes not just Changes line";
99 $cached[0] =~ /^\+\+\+ .\/Changes\n/ or die "Changes not changed";
100 $cached[1] eq "+$changes_line" or die "Changes new line should be: \n\n$changes_line ";
105 our @ISA = @ExtUtils::MM::ISA;
106 @ExtUtils::MM::ISA = (__PACKAGE__);
109 my ($class, $args) = @_;
110 return $class->SUPER::new({
113 AUTHOR => $Distar::Author,
114 ABSTRACT_FROM => $args->{VERSION_FROM},
115 test => { TESTS => ($args->{test}{TESTS}||'t/*.t').' xt/*.t' },
121 my $dist_test = $self->SUPER::dist_test(@_) . <<'END';
123 # --- Distar section:
125 perl -IDistar/lib -MDistar -erun_preflight $(VERSION)
129 $(MAKE) $(DISTVNAME).tar$(SUFFIX)
130 git commit -a -m "Release commit for $(VERSION)"
131 git tag v$(VERSION) -m "release v$(VERSION)"
132 cpan-upload $(DISTVNAME).tar$(SUFFIX)
133 git push origin v$(VERSION) HEAD
135 readmefile: create_distdir
136 pod2text $(VERSION_FROM) >$(DISTVNAME)/README
137 $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) ../Distar/helpers/add-readme-to-manifest
140 if (open my $fh, '<', 'maint/Makefile.include') {
141 $dist_test .= do { local $/; <$fh> };
148 write_manifest_skip() unless $Ran_Preflight