ADAMK-Release
view release on metacpan or search on metacpan
lib/ADAMK/Release.pm view on Meta::CPAN
my $dist_name = $self->dist;
unless ( $merged =~ /L\<http\:\/\/rt\.cpan\.org\/.+?=([\w-]+)\>/ ) {
$self->error("Failed to find a link to the public RT queue");
}
unless ( $dist_name eq $1 ) {
$self->error("Expected a public link to $dist_name RT queue, but found a link to the $1 queue");
}
}
}
# Touch all files to correct any potential time skews
foreach my $file ( $self->find_files->in( $self->dist_dir ) ) {
$self->shell(
$self->bin_touch,
$file,
"Error while touching $file to prevent clock skew",
);
}
return;
}
sub build {
my $self = shift;
# Prevent environment variables from outside this script
# infecting the way we build things inside here.
local $ENV{AUTOMATED_TESTING} = '';
local $ENV{RELEASE_TESTING} = '';
# Run either of the build protocols
if ( $self->makefile_pl ) {
$self->build_make;
} elsif ( $self->build_pl ) {
$self->build_perl;
} else {
$self->error("Module does not have a Makefile.PL or Build.PL");
}
# Double check that the build produced a tarball where we expect it to be
unless ( -f $self->dist_tardist ) {
$self->error(
"Failed to create tardist at '%s'",
$self->dist_tardist,
);
}
return;
}
sub build_make {
my $self = shift;
# Create the Makefile and MANIFEST
$self->build_makefile;
$self->build_makefile_manifest;
unless ( $self->no_test ) {
# Test the distribution normally
$self->shell(
$self->bin_make,
'disttest',
'disttest failed',
);
# Test with AUTOMATED_TESTING on
SCOPE: {
local $ENV{AUTOMATED_TESTING} = 1;
$self->build_makefile;
$self->shell(
$self->bin_make,
"disttest",
'disttest failed',
);
}
# Test with RELEASE_TESTING on
SCOPE: {
local $ENV{RELEASE_TESTING} = 1;
$self->build_makefile;
$self->shell(
$self->bin_make,
"disttest",
'disttest failed',
);
}
# Test with RELEASE_TESTING and root permissions.
# This catches bad test script assumptions in modules related
# to files and permissions (File::Remove, File::Flat etc).
SCOPE: {
local $ENV{RELEASE_TESTING} = 1;
$self->sudo(
qw{ perl Makefile.PL },
'Error while creating Makefile',
);
$self->sudo(
$self->bin_make,
"disttest",
'disttest failed',
);
# Clean up leftover root files and rebuild from scratch
$self->build_realclean;
$self->build_makefile;
$self->build_makefile_manifest;
# Run the test suite one last time to make sure we
# didn't break anything.
$self->sudo(
$self->bin_make,
"disttest",
'disttest failed',
);
# Clean up the leftover root files again
$self->build_realclean;
}
}
# Create the Makefile and MANIFEST
$self->build_makefile;
$self->build_makefile_manifest;
# Build the tardist
$self->shell(
$self->bin_make,
"tardist",
'Error making distribution tarball',
);
return;
}
sub build_makefile {
my $self = shift;
# Execute Makefile.PL with the current environment's perl
$self->shell(
qw{ perl Makefile.PL },
'Error while creating Makefile',
);
# Add the build-system-specific elements to the META.yml
my $meta = YAML::Tiny->read( $self->dist_meta_yml );
return unless defined $meta;
# Add the resources
my $save = 0;
unless ( $meta->[0]->{resources} ) {
$meta->[0]->{resources} = {};
$save = 1;
}
unless ( $meta->[0]->{resources}->{repository} ) {
$meta->[0]->{resources}->{repository} = $self->dist_resource_repository;
$save = 1;
}
if ( $save ) {
$meta->write( $self->dist_meta_yml );
}
return;
}
sub build_makefile_manifest {
my $self = shift;
$self->shell(
$self->bin_make,
"manifest",
"Error while creating the MANIFEST",
);
}
sub build_realclean {
my $self = shift;
# Clean up the distribution (always with root)
$self->sudo(
$self->bin_make,
"realclean",
'sudo make clean failed',
);
$self->remove( $self->dist_manifest );
}
sub build_perl {
my $self = shift;
# Create the Build file
$self->shell(
qw{ perl Build.PL },
'Error while creating Makefile',
);
# Create the MANIFEST file
$self->shell(
"./Build",
"manifest",
'Error while creating the MANIFEST',
);
unless ( $self->no_test ) {
# Test the distribution normally
$self->shell(
qw{ ./Build disttest },
'disttest failed',
);
}
# Build the tardist
$self->shell(
qw{ ./Build dist },
'Error making distribution tarball',
);
return;
}
sub upload {
my $self = shift;
my $pauseid = $self->prompt("PAUSEID:");
unless (_STRING($pauseid) and $pauseid =~ /^[A-Z]{3,}$/) {
$self->error("Missing or invalid PAUSEID");
}
my $password = $self->password("Password:");
unless (_STRING($password) and $password =~ /^\S{5,}$/) {
$self->error("Missing or invalid CPAN password");
}
# Execute the upload to CPAN
CPAN::Uploader->upload_file( $self->dist_tardist, {
user => $pauseid,
password => $password,
});
}
######################################################################
# Content and Scanning Methods
# Get the main github repository url for this release
sub dist_resource_repository {
my $self = shift;
return join( '',
"https://github.com/",
$self->github->username,
$self->github->repository,
'.git',
);
}
sub makefile_pl {
my $self = shift;
unless ( defined $self->{makefile_pl} ) {
my $file = $self->dist_makefile_pl;
return undef unless -f $file;
$self->{makefile_pl} = File::Slurp::read_file($file);
( run in 0.814 second using v1.01-cache-2.11-cpan-39bf76dae61 )