Dist-Zilla-Plugins-CJM
view release on metacpan or search on metacpan
lib/Dist/Zilla/Plugin/ArchiveRelease.pm view on Meta::CPAN
sub pretty_path
{
my ($self, $path) = @_;
my $root = $self->zilla->root;
$path = $path->relative($root) if $root->subsumes($path);
"$path";
} # end pretty_path
#---------------------------------------------------------------------
# Don't distribute previously archived releases:
sub prune_files
{
my $self = shift;
my $root = $self->zilla->root;
my $dir = $self->directory;
if ($root->subsumes($dir)) {
$dir = $dir->relative($root);
my $files = $self->zilla->files;
@$files = grep { not $dir->subsumes($_->name) } @$files;
} # end if archive directory is inside root
return;
} # end prune_files
#---------------------------------------------------------------------
sub before_release
{
my ($self, $tgz) = @_;
my $dir = $self->directory;
# If the directory doesn't exist, create it:
unless (-d $dir) {
my $dirR = $self->pretty_path($dir);
mkdir $dir or $self->log_fatal("Unable to create directory $dirR: $!");
$self->log("Created directory $dirR");
}
# If the tarball has already been archived, abort:
my $file = $dir->child($tgz->basename);
$self->log_fatal($self->pretty_path($file) . " already exists")
if -e $file;
} # end before_release
#---------------------------------------------------------------------
# Main entry point:
sub release
{
my ($self, $tgz) = @_;
chmod(0444, $tgz);
my $dest = $self->directory->child($tgz->basename);
my $destR = $self->pretty_path($dest);
require File::Copy;
File::Copy::move($tgz, $dest)
or $self->log_fatal("Failed to move to $destR: $!");
$self->log("Moved to $destR");
} # end release
#---------------------------------------------------------------------
no Moose;
__PACKAGE__->meta->make_immutable;
1;
__END__
=head1 NAME
Dist::Zilla::Plugin::ArchiveRelease - Move the release tarball to an archive directory
=head1 VERSION
This document describes version 6.000 of
Dist::Zilla::Plugin::ArchiveRelease, released December 17, 2017
as part of Dist-Zilla-Plugins-CJM version 6.000.
=head1 SYNOPSIS
In your F<dist.ini>:
[ArchiveRelease]
directory = releases ; this is the default
=head1 DESCRIPTION
If included, this plugin will cause the F<release> command to mark the
tarball read-only and move it to an archive directory. You can
combine this with another Releaser plugin (like
L<UploadToCPAN|Dist::Zilla::Plugin::UploadToCPAN>), but it must be the
last Releaser in your config (or the other Releasers won't be able to
find the file being released).
It also acts as a FilePruner in order to prevent Dist::Zilla from
including the archived releases in future builds.
=head1 ATTRIBUTES
=head2 directory
The directory to which the tarball will be moved. It may begin with
C<~> (or C<~user>) to mean your (or some other user's) home directory.
Defaults to F<releases>.
If the directory doesn't exist, it will be created during the
BeforeRelease phase.
All files inside this directory will be pruned from the distribution.
( run in 0.785 second using v1.01-cache-2.11-cpan-99c4e6809bf )