App-git-ship
view release on metacpan or search on metacpan
[App::git::ship](https://metacpan.org/pod/App%3A%3Agit%3A%3Aship) is a [git](http://git-scm.com/) command for building and
shipping your project.
The main focus is to automate away the boring steps, but at the same time not
get in your (or any random contributor's) way. Problems should be solved with
sane defaults according to standard rules instead of enforcing more rules.
[App::git::ship](https://metacpan.org/pod/App%3A%3Agit%3A%3Aship) differs from other tools like [dzil](https://metacpan.org/pod/Dist%3A%3AZilla) by _NOT_
requiring any configuration except for a file containing the credentials for
uploading to CPAN.
## Supported project types
Currently, only [App::git::ship::perl](https://metacpan.org/pod/App%3A%3Agit%3A%3Aship%3A%3Aperl) is supported.
# ENVIRONMENT VARIABLES
Environment variables can also be set in a config file named `.ship.conf`, in
the root of the project directory. The format is:
lib/App/git/ship.pm view on Meta::CPAN
L<App::git::ship> is a L<git|http://git-scm.com/> command for building and
shipping your project.
The main focus is to automate away the boring steps, but at the same time not
get in your (or any random contributor's) way. Problems should be solved with
sane defaults according to standard rules instead of enforcing more rules.
L<App::git::ship> differs from other tools like L<dzil|Dist::Zilla> by I<NOT>
requiring any configuration except for a file containing the credentials for
uploading to CPAN.
=head2 Supported project types
Currently, only L<App::git::ship::perl> is supported.
=head1 ENVIRONMENT VARIABLES
Environment variables can also be set in a config file named C<.ship.conf>, in
the root of the project directory. The format is:
lib/App/git/ship/perl.pm view on Meta::CPAN
say "\$ rm $file" unless $self->SILENT;
}
return $self;
}
sub ship {
my $self = shift;
my $dist_file = $self->_dist_files->[0];
my $changelog = $self->config('changelog_filename');
my $uploader;
require CPAN::Uploader;
$uploader = CPAN::Uploader->new(CPAN::Uploader->read_config_file);
unless ($dist_file) {
$self->build;
$self->abort(
"Project built. Run 'git ship' again to post dist to CPAN and remote repostitory.");
}
unless ($self->config('next_version')) {
close ARGV;
local @ARGV = $changelog;
while (<>) {
lib/App/git/ship/perl.pm view on Meta::CPAN
$self->config(next_version => $1);
last;
}
}
$self->run_hook('before_ship');
$self->system(qw(git add Makefile.PL), $changelog);
$self->system(qw(git add README.md)) if -e 'README.md';
$self->system(qw(git commit -a -m), $self->_changes_to_commit_message);
$self->SUPER::ship(@_); # after all the changes
$uploader->upload_file($dist_file);
$self->run_hook('after_ship');
}
sub start {
my $self = shift;
my $changelog = $self->config('changelog_filename');
if (my $file = $_[0]) {
$file = $file =~ m!^.?lib! ? path($file) : path(lib => $file);
$self->config(main_module_path => $file);
lib/App/git/ship/perl.pm view on Meta::CPAN
# Build first if you want to investigate the changes
$ git ship build
# Ship the project to git (and CPAN)
$ git ship ship
=head1 DESCRIPTION
L<App::git::ship::perl> is a module that can ship your Perl module. This tool
differs from other tools like dzil by *NOT* requiring any configuration, except
for a file containing the credentials for uploading to CPAN.
See also L<App::git::ship/DESCRIPTION>.
Example structure and how L<App::git::ship> works on your files:
=over 4
=item * my-app/cpanfile and my-app/Makefile.PL
The C<cpanfile> is used to build the "PREREQ_PM" and "BUILD_REQUIRES"
t/perl-ship-changelog-md.t view on Meta::CPAN
use lib '.';
use t::Util;
use App::git::ship::perl;
t::Util->goto_workdir('perl-changelogmd', 0);
my $app = App::git::ship->new;
my $upload_file = '';
eval <<'DUMMY' or die $@;
package CPAN::Uploader;
sub new { bless $_[1], $_[0] }
sub read_config_file { {} }
sub upload_file { $upload_file = $_[1] }
$INC{'CPAN/Uploader.pm'} = 'dummy';
DUMMY
$app = $app->start('Perl/Changelogmd.pm', 0);
ok -e 'Changes', 'Changes was generated by start';
unlink 'Changes';
write_alien_files();
diag 'Build';
$app->config(new_version_format => '## %v (%F)');
eval { $app->ship };
like $@, qr{Project built}, 'Project built';
is $upload_file, '', 'CPAN::Uploader did not upload anything';
local @ARGV = ('CHANGELOG.md');
my $changes = do { local $/; <>; };
like $changes, qr{^\#\#\s0\.04\s\(\w+}s, 'changes was updated with timestamp';
diag 'Ship';
$upload_file = '';
eval { $app->ship };
is $@, '', 'no ship error';
like $upload_file, qr{\bPerl-Changelogmd-0\.04\.tar\.gz$}, 'CPAN::Uploader uploaded version 0.04';
ok !-e 'Changes', 'Changes is not here';
ok !-e 'README', 'README is not here';
done_testing;
sub write_alien_files {
diag 'Init alien files';
open my $CHANGES, '>', 'CHANGELOG.md';
t/perl-ship.t view on Meta::CPAN
t::Util->goto_workdir('perl-ship', 0);
{
# 0.07: test to see if perldoc -tT should work
open my $FH, '>', 'README'
or plan
skip_all => sprintf 'Could not touch README in %s',
Cwd::getcwd;
}
my $upload_file;
eval <<'DUMMY' or die $@;
package CPAN::Uploader;
sub new { bless $_[1], $_[0] }
sub read_config_file { {} }
sub upload_file { $upload_file = $_[1] }
$INC{'CPAN/Uploader.pm'} = 'dummy';
DUMMY
diag 'First release';
my $app = App::git::ship->new;
$app = $app->start('Perl/Ship.pm', 0);
$upload_file = '';
create_bad_main_module();
eval { $app->ship };
like $@, qr{Could not update VERSION in}, 'Could not update VERSION';
create_main_module();
eval { $app->ship };
like $@, qr{Project built}, 'Project built';
eval { $app->ship };
is $@, '', 'no ship error';
like $upload_file, qr{\bPerl-Ship-0\.01\.tar\.gz$}, 'CPAN::Uploader uploaded version 0.01';
is eval { $app->clean }, $app, 'clean up after release' or diag $@;
diag 'Second release';
$app = App::git::ship->new;
bless $app, $app->detect;
$upload_file = '';
ok !$app->config('next_version'), 'no next_version yet';
eval { $app->ship };
like $@, qr{Unable to add timestamp}, 'Unable to add timestamp';
{
local @ARGV = ('Changes');
local $^I = '';
while (<>) {
print "0.02 Not Released\n - Some other cool feature\n\n" if $. == 3;
print;
}
}
$app->build->ship;
is $app->config('next_version'), '0.02', 'next_version is 0.02';
like $upload_file, qr{\bPerl-Ship-0\.02\.tar\.gz$}, 'CPAN::Uploader uploaded version 0.01';
done_testing;
sub create_bad_main_module {
open my $MAIN_MODULE, '>', File::Spec->catfile(qw(lib Perl Ship.pm)) or die $!;
print $MAIN_MODULE "package Perl::Ship;\n=head1 NAME\n\nPerl::Ship\n\n1";
}
sub create_main_module {
open my $MAIN_MODULE, '>', File::Spec->catfile(qw(lib Perl Ship.pm)) or die $!;
( run in 1.997 second using v1.01-cache-2.11-cpan-b16cb0d3907 )