3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-16 00:49:35 +01:00
pbot/misc/update-version
2021-07-13 19:45:56 -07:00

40 lines
985 B
Perl
Executable File
Vendored

#!/usr/bin/env perl
# File: update-version
#
# Purpose: Updates version information in PBot/VERSION.pm
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT
use warnings;
use strict;
use POSIX qw(strftime);
# my $svn_info = `svn info -r head` or die "Couldn't get revision: $!";
# my ($rev) = $svn_info =~ /Last Changed Rev: (\d+)/;
my $rev = `git rev-list --count HEAD`;
my $date = strftime "%Y-%m-%d", localtime;
$rev++;
print "New version: $rev $date\n";
open my $in, '<', "lib/PBot/VERSION.pm" or die "Couldn't open VERSION.pm for reading: $!";
my @lines = <$in>;
close $in;
open my $out, '>', "lib/PBot/VERSION.pm" or die "Couldn't open VERSION.pm for writing: $!";
foreach my $text (@lines) {
$text =~ s/BUILD_NAME\s+=> ".*",/BUILD_NAME => "PBot",/;
$text =~ s/BUILD_REVISION\s+=> \d+,/BUILD_REVISION => $rev,/;
$text =~ s/BUILD_DATE\s+=> ".*",/BUILD_DATE => "$date",/;
print $out $text;
}
close $out;