don't force remake on Distar change
[p5sagit/Distar.git] / lib / Distar.pm
index b702c80..9845bd9 100644 (file)
@@ -4,6 +4,7 @@ use warnings FATAL => 'all';
 use base qw(Exporter);
 use ExtUtils::MakeMaker ();
 use ExtUtils::MM ();
+use File::Spec ();
 
 our $VERSION = '0.002000';
 $VERSION = eval $VERSION;
@@ -103,6 +104,7 @@ sub write_manifest_skip {
       preflight
       check-version
       check-manifest
+      check-cpan-upload
       releasetest
       release
       readmefile
@@ -129,10 +131,20 @@ sub write_manifest_skip {
     my @bump_targets =
       grep { $include !~ /^bump$_(?: +\w+)*:/m } ('', 'minor', 'major');
 
+    my $distar = File::Spec->catdir(
+      File::Spec->catpath((File::Spec->splitpath(__FILE__))[0,1], ''),
+      File::Spec->updir,
+    );
+    my $helpers = File::Spec->catdir($distar, 'helpers');
+
     my %vars = (
+      DISTAR => $self->quote_literal($distar),
+      HELPERS => $self->quote_literal($helpers),
       REMAKE => join(' ', '$(PERLRUN)', 'Makefile.PL', map { $self->quote_literal($_) } @ARGV),
       BRANCH => $self->{BRANCH} ||= 'master',
       CHANGELOG => $self->{CHANGELOG} ||= 'Changes',
+      DEV_NULL_STDOUT => ($self->{DEV_NULL} ? '>'.File::Spec->devnull : ''),
+      FAKE_RELEASE => '',
     );
 
     join('',
@@ -141,19 +153,26 @@ sub write_manifest_skip {
       (map "$_ = $vars{$_}\n", sort keys %vars),
       <<'END',
 
-preflight: check-version check-manifest
-       $(ABSPERLRUN) Distar/helpers/preflight $(VERSION) --changelog=$(CHANGELOG) --branch=$(BRANCH)
+preflight: check-version check-manifest check-cpan-upload
+       $(ABSPERLRUN) $(HELPERS)/preflight $(VERSION) --changelog=$(CHANGELOG) --branch=$(BRANCH)
 check-version:
-       $(ABSPERLRUN) Distar/helpers/check-version $(VERSION) $(TO_INST_PM) $(EXE_FILES)
+       $(ABSPERLRUN) $(HELPERS)/check-version $(VERSION) $(TO_INST_PM) $(EXE_FILES)
 check-manifest:
-       $(ABSPERLRUN) Distar/helpers/check-manifest
+       $(ABSPERLRUN) $(HELPERS)/check-manifest
+check-cpan-upload:
+       $(NOECHO) cpan-upload -h $(DEV_NULL_STDOUT)
 releasetest:
        $(MAKE) disttest RELEASE_TESTING=1 PASTHRU="$(PASTHRU) TEST_FILES=\"$(TEST_FILES)\""
-release: preflight releasetest
-       $(RM_RF) $(DISTVNAME)
-       $(MAKE) $(DISTVNAME).tar$(SUFFIX)
+release: preflight
+       $(MAKE) releasetest
        git commit -a -m "Release commit for $(VERSION)"
        git tag v$(VERSION) -m "release v$(VERSION)"
+       $(RM_RF) $(DISTVNAME)
+       $(MAKE) $(DISTVNAME).tar$(SUFFIX)
+       $(NOECHO) $(MAKE) pushrelease FAKE_RELEASE=$(FAKE_RELEASE)
+pushrelease ::
+       $(NOECHO) $(NOOP)
+pushrelease$(FAKE_RELEASE) ::
        cpan-upload $(DISTVNAME).tar$(SUFFIX)
        git push origin v$(VERSION) HEAD
 distdir: readmefile
@@ -162,20 +181,20 @@ readmefile: create_distdir
 $(DISTVNAME)/README: $(VERSION_FROM)
        $(NOECHO) $(MKPATH) $(DISTVNAME)
        pod2text $(VERSION_FROM) >$(DISTVNAME)/README
-       $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) ../Distar/helpers/add-to-manifest README
+       $(NOECHO) $(ABSPERLRUN) $(HELPERS)/add-to-manifest -d $(DISTVNAME) README
 disttest: distmanicheck
 distmanicheck: create_distdir
        cd $(DISTVNAME) && $(ABSPERLRUN) "-MExtUtils::Manifest=manicheck" -e "exit manicheck"
 nextrelease:
-       $(ABSPERLRUN) Distar/helpers/add-changelog-heading --git $(VERSION) $(CHANGELOG)
+       $(ABSPERLRUN) $(HELPERS)/add-changelog-heading --git $(VERSION) $(CHANGELOG)
 refresh:
-       cd Distar && git pull
+       cd $(DISTAR) && git pull
        $(RM_F) $(FIRST_MAKEFILE)
        $(REMAKE)
 END
       map(sprintf(<<'END', "bump$_", ($_ || '$(V)')), @bump_targets),
 %s:
-       $(ABSPERLRUN) Distar/helpers/bump-version --git $(VERSION) %s
+       $(ABSPERLRUN) $(HELPERS)/bump-version --git $(VERSION) %s
        $(RM_F) $(FIRST_MAKEFILE)
        $(REMAKE)
 END
@@ -289,6 +308,11 @@ C<preflight> and C<releasetest> commands.
 Releasing will generate a dist tarball and upload it to CPAN using cpan-upload.
 It will also create a git tag for the release, and push the tag and branch.
 
+=head2 FAKE_RELEASE
+
+If release is run with FAKE_RELEASE=1 set, it will skip uploading to CPAN and
+pushing to git.  A release commit will still be created and tagged locally.
+
 =head2 preflight
 
 Performs a number of checks on the files and repository, ensuring it is in a