-
Notifications
You must be signed in to change notification settings - Fork 23
/
bump_version
118 lines (107 loc) · 3.71 KB
/
bump_version
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
# Copyright 2022 Jeffrey Kegler
# This file is part of Marpa::R2. Marpa::R2 is free software: you can
# redistribute it and/or modify it under the terms of the GNU Lesser
# General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# Marpa::R2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser
# General Public License along with Marpa::R2. If not, see
# http://www.gnu.org/licenses/.
#!/usr/bin/env perl
use 5.010001;
use strict;
use warnings FATAL => 'all';
use autodie;
use English qw( -no_match_vars );
use IPC::Cmd;
my $latest;
LINE: {
open my $changes_fh, q{<}, 'cpan/Changes';
while ( my $line = <$changes_fh> ) {
if ( $line =~ m/ \A \d /xms ) {
$latest = $line;
chomp $latest;
last LINE;
}
} ## end while ( my $line = <$changes_fh> )
} ## end LINE:
die "Could not find latest change" if not defined $latest;
warn "Bumping -> $latest\n";
my ( $major, $minor, $underscore, $micro, $libmarpa_major, $libmarpa_minor,
$libmarpa_micro )
= (
$latest =~ m/\A
(\d+) [.] (\d\d\d) ([_]?) (\d\d\d)
\s+ [(] libmarpa \s+ (\d+) [.] (\d+) [.] (\d+) [)]
/xms
);
if ( not defined $libmarpa_micro ) {
die "bump_version Cannot handle new version number: $latest";
}
$major += 0;
$minor += 0;
$micro += 0;
my $perlish_version = sprintf '%d%s%.3d%s%.3d', $major, q{.}, $minor,
$underscore, $micro;
my @versioned_files = split /\n/xms, <<'END_OF_LIST';
cpan/html/lib/Marpa/R2/HTML.pm
cpan/html/lib/Marpa/R2/HTML.pm
cpan/html/lib/Marpa/R2/HTML/Callback.pm
cpan/html/lib/Marpa/R2/HTML/Config.pm
cpan/html/lib/Marpa/R2/HTML/Config/Compile.pm
cpan/html/meta/make_internal_pm.pl
cpan/html/tool/lib/Marpa/R2/HTML/Test/Util.pm
cpan/lib/Marpa/R2/ASF.pm
cpan/lib/Marpa/R2/Grammar.pm
cpan/lib/Marpa/R2/MetaAST.pm
cpan/lib/Marpa/R2/MetaG.pm
cpan/lib/Marpa/R2.pm
cpan/lib/Marpa/R2/Recognizer.pm
cpan/lib/Marpa/R2/SLG.pm
cpan/lib/Marpa/R2/SLR.pm
cpan/lib/Marpa/R2/Stuifzand.pm
cpan/lib/Marpa/R2/Thin/Trace.pm
cpan/lib/Marpa/R2/Value.pm
cpan/meta/make_internal_pm.pl
END_OF_LIST
for my $versioned_file (@versioned_files) {
say STDERR $versioned_file;
my $file = do { local ( @ARGV, $/ ) = ($versioned_file); <> };
$file =~ s/(\$VERSION \s+ = \s+ ['] ) \d+ [.] \d\d\d [_]? \d\d\d /$1${perlish_version}/xms;
open my $out, '>', $versioned_file;
print $out $file;
} ## end for my $versioned_file (@versioned_files)
{
# Update the version of Libmarpa that XS is expecting
my $expecting_file = 'cpan/xs/R2.xs';
say STDERR $expecting_file;
my $file = do { local ( @ARGV, $/ ) = ($expecting_file); <> };
$file =~ s{
^ [#]define \s+ EXPECTED_LIBMARPA_MAJOR \s [^\n]* $}
{#define EXPECTED_LIBMARPA_MAJOR $libmarpa_major}xms;
$file =~ s{
^ [#]define \s+ EXPECTED_LIBMARPA_MINOR \s [^\n]* $}
{#define EXPECTED_LIBMARPA_MINOR $libmarpa_minor}xms;
$file =~ s{
^ [#]define \s+ EXPECTED_LIBMARPA_MICRO \s [^\n]* $}
{#define EXPECTED_LIBMARPA_MICRO $libmarpa_micro}xms;
open my $out, '>', $expecting_file;
print $out $file;
}
chdir 'cpan';
die qq{"perl Build.PL" failed: $!}
if not IPC::Cmd::run(
command => [ $EXECUTABLE_NAME, 'Build.PL' ],
verbose => 1
);
die qq{"./Build distmeta" failed: $!}
if
not IPC::Cmd::run( command => [ './Build', 'distmeta' ], verbose => 1 );
chdir 'meta';
die qq{"make all" in cpan/meta/ directory failed: $!}
if not IPC::Cmd::run( command => [ 'make', 'all' ], verbose => 1 );