Skip to content

Commit 2fdee25

Browse files
committed
Add version tag injection in the build pipeline
1 parent 35b6240 commit 2fdee25

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

utils/scripts/build/linux-build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ sudo chown eqemu:eqemu /home/eqemu/.ccache/ * -R
77

88
git submodule init && git submodule update
99

10+
perl utils/scripts/build/tag-version.pl
11+
1012
mkdir -p build && cd build && cmake -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_LUA=ON -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="-Os" -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G 'Unix Makefiles' .. && make -j$((`nproc`-4))
1113

1214
curl https://raw.githubusercontent.com/Akkadius/eqemu-install-v2/master/eqemu_config.json --output eqemu_config.json

utils/scripts/build/tag-version.pl

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/perl
2+
use strict;
3+
use warnings FATAL => 'all';
4+
5+
open my $fh, '<', './package.json' or die "Can't open file $!";
6+
my $package_json = do {
7+
local $/;
8+
<$fh>
9+
};
10+
11+
my $version = "";
12+
sub trim($)
13+
{
14+
my $string = shift;
15+
$string =~ s/^\s+//;
16+
$string =~ s/\s+$//;
17+
return $string;
18+
}
19+
20+
# manually parse because we can't guarantee json module is available
21+
# it's jank but it's quick and dirty
22+
# this is only used in the build pipeline
23+
foreach my $line (split("\n", $package_json)) {
24+
if ($line =~ /version/i) {
25+
$version = $line;
26+
$version =~ s/version//g;
27+
$version =~ s/://g;
28+
$version =~ s/"//g;
29+
$version =~ s/,//g;
30+
$version = trim($version);
31+
}
32+
}
33+
34+
print "Version is [" . $version . "]\n";
35+
36+
# server version file
37+
my $version_file_name = "./common/version.h";
38+
open my $vfh, '<', $version_file_name or die "Can't open file $!";
39+
my $version_file = do {
40+
local $/;
41+
<$vfh>
42+
};
43+
44+
# write new version
45+
my $new_version_file = "";
46+
foreach my $line (split("\n", $version_file)) {
47+
if ($line =~ /CURRENT_VERSION/i) {
48+
my @s = split("\"", $line);
49+
if ($#s == 2) {
50+
$line =~ s/$s[1]/$version/g;
51+
}
52+
}
53+
54+
$new_version_file .= $line . "\n";
55+
}
56+
57+
open(my $wfh, '>', $version_file_name) or die "Could not open file '$version_file_name' $!";
58+
print $wfh $new_version_file;
59+
close $wfh;
60+
61+
print $new_version_file;

utils/scripts/build/windows-build.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ try
1313
New-Item -Path "$cwd\win-build-x64" -ItemType Directory
1414
}
1515

16+
perl .\utils\scripts\build\tag-version.pl
17+
1618
Write-Information -MessageData "Creating build x64" -InformationAction Continue
1719
Set-Location -Path "$cwd\win-build-x64"
1820
cmake -Wno-dev -G "Visual Studio 17 2022" -A x64 -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_ZLIB=ON "$cwd"

0 commit comments

Comments
 (0)