#!/usr/bin/perl
use 5.010;
use strict;
use constant BITBUCKET_USERNAME => 'tobyink';
use constant BITBUCKET_PASSWORD => 'my secret';
use Cwd;
use Path::Class qw/dir/;
use String::Escape qw/printable/;
use URI::Escape qw/uri_escape/;
sub default_name
{
[dir(cwd)->dir_list]->[-1]
}
sub new_bitbucket
{
my %options = @_;
$options{name} //= default_name();
$options{scm} //= 'hg';
$options{has_wiki} //= 'True';
my $body = join '&', map { sprintf('%s=%s', uri_escape($_), uri_escape($options{$_})) } sort keys %options;
my $cmd = sprintf("curl -S -s -X POST -u %s:%s '%s' -d '%s'",
BITBUCKET_USERNAME,
BITBUCKET_PASSWORD,
'https://api.bitbucket.org/1.0/repositories/',
printable($body),
);
my $res = `$cmd`;
say $res;
return $options{name};
}
sub hg_init
{
system 'hg init';
}
sub hgrc
{
open my $fh, '>', '.hg/hgrc';
say $fh '[paths]';
say $fh 'default = ssh://hg@bitbucket.org/', BITBUCKET_USERNAME, '/', shift;
}
hg_init();
hgrc( new_bitbucket() );
####
assertos qw(Linux FreeBSD Cygwin);
####
perl Makefile.PL && \
make all test dist && \
make clean && \
rm Makefile.old
####
cpanm !^ && \
cpan-upload !^ && \
mv !^ ~/perl5/published/ && \
echo "Do not forget to hg tag the release."