Initial commit of bump-version.pl
This commit is contained in:
parent
e5ac6e95fa
commit
21b41f198a
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
# This script will bump the version number in any files listed in the below
|
||||
# @files array. It can only bump versions up, and does so by use of sed.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long;
|
||||
|
||||
my @files = (
|
||||
"../version",
|
||||
"../configure.ac"
|
||||
);
|
||||
|
||||
|
||||
my ($new, $current);
|
||||
|
||||
open my $file, "../version" or die $!;
|
||||
chomp($current = <$file>);
|
||||
close $file;
|
||||
|
||||
sub usage {
|
||||
print "Usage: bump-version.sh -n <new-version>\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
sub bump_version {
|
||||
foreach my $file (@files) {
|
||||
system("sed -i \"s/$current/$new/g\" $file");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GetOptions ("n=s" => \$new) or usage;
|
||||
usage if ! $new;
|
||||
die("New version ($new) is not greater than old version ($current)!") if ( $new le $current);
|
||||
|
||||
bump_version;
|
Loading…
Reference in New Issue