move Author.PL to maint/Makefile.PL.include to prevent it being run at build time
[p5sagit/Module-Metadata.git] / maint / bump-version
CommitLineData
534471a1 1#!/usr/bin/env perl
2
3use 5.010;
4use strict;
5use warnings FATAL => 'all';
6use autodie;
7
8chomp(my $LATEST = qx(grep '^[0-9]' Changes | head -1 | awk '{print \$1}'));
9
10my @parts = split /\./, $LATEST;
11
12my $OLD_DECIMAL = sprintf('%i.%03i%03i', @parts);
13
14my %bump_part = (major => 0, minor => 1, bugfix => 2);
15
16my $bump_this =
17 $bump_part{$ARGV[0]||'bugfix'}
18 // die "no idea which part to bump - $ARGV[0] means nothing to me";
19
20my @new_parts = @parts;
21
22$new_parts[$bump_this]++;
23
24my $NEW_DECIMAL = sprintf('%i.%03i%03i', @new_parts);
25
26warn "Bumping $OLD_DECIMAL -> $NEW_DECIMAL\n";
27
28my $PM_FILE = 'lib/Module/Metadata.pm';
29
30my $file = do { local (@ARGV, $/) = ($PM_FILE); <> };
31
32$file =~ s/(?<=\$VERSION = ')${\quotemeta $OLD_DECIMAL}/${NEW_DECIMAL}/;
33
34open my $out, '>', $PM_FILE;
35
36print $out $file;