Commit | Line | Data |
253d7c99 |
1 | #!/usr/bin/env perl |
2 | |
253d7c99 |
3 | use strict; |
4 | use warnings FATAL => 'all'; |
5 | use autodie; |
6 | |
7 | chomp(my $LATEST = qx(grep '^[0-9]' Changes | head -1 | awk '{print \$1}')); |
8 | |
9 | my @parts = split /\./, $LATEST; |
10 | |
11 | my $OLD_DECIMAL = sprintf('%i.%03i%03i', @parts); |
12 | |
13 | my %bump_part = (major => 0, minor => 1, bugfix => 2); |
14 | |
5d5bb71d |
15 | my $bump_this = $bump_part{$ARGV[0]||'bugfix'}; |
16 | |
17 | die "no idea which part to bump - $ARGV[0] means nothing to me" |
18 | unless defined($bump_this); |
253d7c99 |
19 | |
20 | my @new_parts = @parts; |
21 | |
22 | $new_parts[$bump_this]++; |
23 | |
24 | my $NEW_DECIMAL = sprintf('%i.%03i%03i', @new_parts); |
25 | |
26 | warn "Bumping $OLD_DECIMAL -> $NEW_DECIMAL\n"; |
27 | |
5d5bb71d |
28 | my $PM_FILE = 'lib/Moo.pm'; |
253d7c99 |
29 | |
30 | my $file = do { local (@ARGV, $/) = ($PM_FILE); <> }; |
31 | |
32 | $file =~ s/(?<=\$VERSION = ')${\quotemeta $OLD_DECIMAL}/${NEW_DECIMAL}/; |
33 | |
34 | open my $out, '>', $PM_FILE; |
35 | |
36 | print $out $file; |