mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
version bump script
This commit is contained in:
parent
206ff25e1a
commit
94d9bf1766
1 changed files with 64 additions and 0 deletions
64
Utils/version-bump.pl
Normal file
64
Utils/version-bump.pl
Normal file
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use File::Copy;
|
||||
use File::Find;
|
||||
|
||||
open ROOTPOM, "< ../pom.xml" or die;
|
||||
|
||||
my $oldversion;
|
||||
while (<ROOTPOM>) {
|
||||
my $line = $_;
|
||||
if ($line =~ m/mage-version>(.*)</) {
|
||||
print "Current version: $1\n";
|
||||
$oldversion = $1;
|
||||
}
|
||||
}
|
||||
|
||||
print "Enter new version: ";
|
||||
my $version = <STDIN>;
|
||||
chomp $version;
|
||||
|
||||
#find(\&finded, "..");
|
||||
update_version_in_java("../Mage.CLient/src/main/java/mage/client/MageFrame.java");
|
||||
update_version_in_java("../Mage.Server/src/main/java/mage/server/Main.java");
|
||||
update_version_in_java("../Mage.Server.Console/src/main/java/mage/server/console/ConsoleFrame.java");
|
||||
|
||||
sub finded {
|
||||
if (/pom\.xml/) {
|
||||
update_version($_);
|
||||
}
|
||||
}
|
||||
|
||||
sub update_version {
|
||||
my ($filename) = @_;
|
||||
open POM, "< $filename" or die;
|
||||
open NEWPOM, "> $filename.new" or die;
|
||||
while (<POM>) {
|
||||
s/version>$oldversion/version>$version/g;
|
||||
print NEWPOM $_;
|
||||
}
|
||||
close POM;
|
||||
close NEWPOM;
|
||||
move("$filename.new", "$filename");
|
||||
}
|
||||
|
||||
sub update_version_in_java {
|
||||
my ($filename) = @_;
|
||||
open FILE, "< $filename" or die;
|
||||
open NEWFILE, "> $filename.new" or die;
|
||||
$version =~m/(.)\.(.)\.(.)/;
|
||||
my ($f, $s, $t) = ($1, $2, $3);
|
||||
$oldversion =~m/(.)\.(.)\.(.)/;
|
||||
my ($of, $os, $ot) = ($1, $2, $3);
|
||||
print "f - $f, s - $s, t - $t\n";
|
||||
while (<FILE>) {
|
||||
s/new MageVersion\($of, $os, $ot,/new MageVersion\($f, $s, $t,/;
|
||||
print NEWFILE $_;
|
||||
}
|
||||
close FILE;
|
||||
close NEWFILE;
|
||||
move("$filename.new", "$filename");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in a new issue