Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 390 lines (254 sloc) 9.498 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
#!/usr/bin/perl

eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
    if 0; # not running under some shell
use strict;
use warnings;

# $Id: release,v 1.1 2007/09/04 17:59:38 dsaff Exp $

=head1 NAME

release - upload files to the CPAN and SourceForge.net

=head1 SYNOPSIS

release [ LOCAL_FILE [ REMOTE_FILE ] ]
# try a dry run without uploading anything
release -t
# print a help message
release -h
# print debugging information
release -d

=head1 DESCRIPTION

This is the prototype program for using Module::Release. You should
modify it to fit your needs.

This program automates Perl module releases. It makes the
distribution, tests it, checks that source control is up to date, tags
source control, uploads it to the PAUSE anonymous FTP directory and to
the incoming directory for SourceForge.net, claims it on PAUSE for
your CPAN account, and releases it on SourceForge.net.

By default this script assumes that you use CVS, but recognizes SVN
and switches when appropriate.

=head2 Process

The release script checks many things before it actually releases the
file. Some of these are annoying, but they are also the last line of
defense against releasing bad distributions.

=over 4

=item Read the configuration data

Look in the current working directory for C<.releaserc>. See the
Configuration section. If release cannot find the configuration file,
it dies.

=item Test and make the distribution

Run make realclean, perl Makefile.PL, make test, make dist, make
disttest. If testing fails, release dies. make dist provides the
name of the distribution if LOCAL_FILE is not provided on the command
line.

=item Check that source control is up-to-date

If there are modified files, added files, or extra files so that
source control complains, fail.

=item Upload to PAUSE and SourceForge.net

Simply drop the distribution in the incoming/ directory of these
servers.

=item Claim the file on PAUSE

Connect to the PAUSE web thingy and claim the uploaded file for your
CPAN account.

=item Tag the repository

Use the version number (in the distribution name) to tag the
repository. You should be able to checkout the code from any release.

=item Release to SourceForge.net

The release name is the distribution name without the .tar.gz. The
file name is the distribution name. SourceForge.net divides things
into projects (with project IDs) and packages within the project (with
package IDs). Specify these in the configuration file.

=back

=head2 Configuration

The release script uses a configuration file in the current working
directory. The file name is F<.releaserc>. Although most of the
information is the same for all of your projects, the C<sf_package_id>
is probably different. You can get the C<sf_package_id> from the data
in the Quick Release Form.

release's own F<.releaserc> looks like this:

sf_user comdog
sf_group_id 36221
sf_package_id 56559
cpan_user BDFOY

=over 4

=item cpan_user

=item sf_user

If C<cpan_user> or C<sf_user> is set to C<< <none> >>, the program will
skip releasing for that system. You must release for at least one system.

=item sf_group_id

=item sf_package_id

=item sf_processor_id

=item sf_type_id

=item sf_release_match

=item sf_release_replace

To find C<sf_package_id> and C<sf_group_id>, go to the Add/Edit
Release page for your project. The link for "[Add Release]" might
look something like this (this is the link for the F<release> package
itself):

https://sourceforge.net/project/admin/newrelease.php?package_id=56559&group_id=36221

so C<sf_package_id> is 56559 and C<sf_group_id> is 36221.

C<sf_processor_id> and C<sf_type_id> are optional, and default to "Any"
and "Source .gz". See the HTML in a file release form on SourceForge.net
for other options.

C<sf_release_match> and C<sf_release_replace> are for defining the release
name, if you don't like the default. For example, the default would
set the name for this program to something like "release-0.10".
But if you want the name to be only the version number, set
C<sf_release_match=^.+-([\d.]+)$> and C<sf_release_replace=$1>.

=item passive_ftp

Set C<passive_ftp> to "y" or "yes" for passive FTP transfers. Usually
this is to get around a firewall issue.

=item release_subclass

Specify the name of a subclass to use instead of Module::Release. The
subclass can override any of the Module::Release methods. This makes
it possible to maintain your own local releasing procedures. For
instance, one such subclass might look like this:

package Module::Release::KWILLIAMS;
use base qw(Module::Release);
sub make_cvs_tag {
my $self = shift;
(my $version) = $self->{remote} =~ / - (\d[\w.]*) \.tar \.gz $/x;
$version =~ s/[^a-z0-9_]/_/gi;
return "release-$version";
}
1;

To use this subclass, you'd put it in your C<@INC> somewhere, then set
C<release_subclass> to C<Module::Release::KWILLIAMS>.

=back

=head2 Environment

=over 4

=item * CPAN_PASS

=item * SF_PASS

release reads the C<CPAN_PASS> and C<SF_PASS> environment variables to
set the passwords for PAUSE and SourceForge.net, respectively. Of course,
you don't need to set the password for a system you're not uploading to.

=item * RELEASE_DEBUG

The C<RELEASE_DEBUG> environment variable sets the debugging value,
which is 0 by default. Set C<RELEASE_DEBUG> to a true value to get
debugging output.

=item * PERL

The C<PERL> environment variable sets the path to perl for use in the
make; otherwise, the perl used to run release will be used.

=back

=head1 TO DO

=over 4

=item * check make disttest (to catch MANIFEST errors) -- needs error catching and reporting

=back

=head1 SOURCE AVAILABILITY

This source is part of a SourceForge.net project which always has the
latest sources in CVS, as well as all of the previous releases.

http://sourceforge.net/projects/brian-d-foy/

If, for some reason, I disappear from the world, one of the other
members of the project can shepherd this software appropriately.

=head1 AUTHOR

brian d foy, C<< <bdfoy@cpan.org> >>

=head1 COPYRIGHT AND LICENSE

Copyright 2002-2007, brian d foy, All rights reserved.

You may use this software under the same terms as Perl itself.

=head1 CREDITS

Ken Williams turned the original release(1) script into a module.

Andy Lester contributed to the module and script.

=cut

use Getopt::Std;
use Module::Release;

my $class = "Module::Release";


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
my %opts;
getopts('hdt', \%opts) or $opts{h} = 1;

if( $opts{h} )
{
print <<"USE";

Use: release -hdt [ LOCAL_FILE [ REMOTE_FILE ] ]

Will upload current release LOCAL_FILE, naming it REMOTE_FILE. Will
get LOCAL_FILE and REMOTE_FILE automatically (using same name for
both) if not supplied.

-h This help
-d Print extra debugging information
-t Just make and test distribution, don't tag/upload

The program works in the current directory, and looks for a .releaserc
or releaserc file and the environment for its preferences. See
`perldoc $0`, for more information.

USE

exit;
}


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
if( -d '.svn' )
{
$class = "Module::Release::Subversion";

print STDERR "I see an .svn directory, so I'm loading $class"
if $opts{d};

eval "use Module::Release::Subversion";
die "Could not load $class: $@\n" if $@;
}

my( $script_version ) =
sprintf "%1.%02d", q$Revision: 1.1 $ =~ m/ (\d+) /xg;


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
my %params;
$params{local} = shift @ARGV if @ARGV;

if( @ARGV )
{
    $params{remote} = shift @ARGV;
}
elsif( $params{local} )
{
    $params{remote} = $params{local};
}

$params{debug} = 1 if $opts{d};

my $release = $class->new( %params );

print STDERR "release $script_version, using $class " . $class->VERSION . "\n"
if $release->debug;


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
$release->clean;
$release->build_makefile;
$release->test;
$release->dist;
$release->check_kwalitee;
$release->dist_test;
# $release->check_cvs;

my $Version = $release->dist_version;

print STDERR "dist version is $Version\n" if $release->debug;

exit if $opts{t};


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
my $Changes = do {
my $changes = "Changes";
my $bak = $changes . ".bak";

die "Changes file does not exist!\n" unless -e $changes;

print "\n", "-" x 73, "\n", "Enter Changes section\n\n> ";

my $str = $Version . " - " . localtime() . "\n";

while( <STDIN> )
{
$_ =~ s/^(\S)/\t$1/; # always indent

$str .= $_;
print "> ";
}

$str .= "\n";

rename $changes, $bak or die "Could not backup $changes. $!\n";
open my $in, $bak or die "Could not read old $changes file! $!\n";
open my $out, ">", $changes;

while( <$in> )
{
print $out $_;
last unless m/\S/;
}

print $out $str;

print $out $_ while( <$in> );

close $in;
close $out;

my $command = do {
if( -d 'CVS' ) { 'cvs' }
elsif( -d '.svn' ) { 'svn' }
};

my $cvs_commit = `$command commit -m "* for version $Version" 2>&1`;

print $cvs_commit;

$str;
};


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
$release->clean;
$release->build_makefile;
$release->dist;

$release->check_for_passwords;
$release->ftp_upload;
$release->pause_claim;
$release->cvs_tag;

$release->sf_login;
$release->sf_qrs;
$release->sf_release;

print "Done.\n";

__END__
Something went wrong with that request. Please try again.