bump version
[gitmo/Moo.git] / maint / bump-version
CommitLineData
253d7c99 1#!/usr/bin/env perl
2
253d7c99 3use strict;
4use warnings FATAL => 'all';
5use autodie;
6
7chomp(my $LATEST = qx(grep '^[0-9]' Changes | head -1 | awk '{print \$1}'));
8
9my @parts = split /\./, $LATEST;
10
11my $OLD_DECIMAL = sprintf('%i.%03i%03i', @parts);
12
13my %bump_part = (major => 0, minor => 1, bugfix => 2);
14
5d5bb71d 15my $bump_this = $bump_part{$ARGV[0]||'bugfix'};
16
17die "no idea which part to bump - $ARGV[0] means nothing to me"
18 unless defined($bump_this);
253d7c99 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
5d5bb71d 28my $PM_FILE = 'lib/Moo.pm';
253d7c99 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;