Skip to content

Commit 79cbb70

Browse files
committed
ci-build updated
+ added plugins.ini to default + added signing + migrated to windows-2025 runner + wmic deprecated and migrated to ps + memamod year is now 2025
1 parent 273618c commit 79cbb70

5 files changed

Lines changed: 190 additions & 12 deletions

File tree

.github/workflows/build.yml

Lines changed: 153 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ on:
1111
types: [opened, reopened, synchronize]
1212
release:
1313
types: [published]
14+
workflow_dispatch:
1415

1516
jobs:
1617
windows:
1718
name: 'Windows'
18-
runs-on: windows-2019
19+
runs-on: windows-2025
1920

2021
env:
2122
solution: 'msvc/metamod.sln'
@@ -28,21 +29,103 @@ jobs:
2829
with:
2930
fetch-depth: 0
3031

32+
# TODO: add support of 141_xp toolchain at VS2022+
33+
# - name: Install v140, v141 and v142 toolsets
34+
# shell: cmd
35+
# run: |
36+
# "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify ^
37+
# --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" ^
38+
# --add Microsoft.VisualStudio.Component.WindowsXP ^
39+
# --add Microsoft.VisualStudio.Component.VC.v140 ^
40+
# --add Microsoft.VisualStudio.Component.VC.v140.x86.x64 ^
41+
# --add Microsoft.VisualStudio.Component.VC.v140.xp ^
42+
# --add Microsoft.VisualStudio.Component.VC.140.CRT ^
43+
# --add Microsoft.VisualStudio.Component.VC.v141 ^
44+
# --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 ^
45+
# --add Microsoft.VisualStudio.Component.VC.v141.xp ^
46+
# --add Microsoft.VisualStudio.Component.VC.v142 ^
47+
# --add Microsoft.VisualStudio.Component.VC.v142.x86.x64 ^
48+
# --quiet --norestart
49+
50+
- name: Select PlatformToolset
51+
id: select_toolset
52+
shell: pwsh
53+
run: |
54+
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
55+
$vs2019 = & $vswhere -products * -version "[16.0,17.0)" -property installationPath -latest
56+
$vs2022 = & $vswhere -products * -version "[17.0,)" -property installationPath -latest
57+
58+
if ($vs2019) {
59+
"toolset=v142" >> $env:GITHUB_OUTPUT
60+
Write-Host "Selected v142"
61+
} elseif ($vs2022) {
62+
"toolset=v143" >> $env:GITHUB_OUTPUT
63+
Write-Host "Selected v143 toolset"
64+
} else {
65+
Write-Error "No suitable Visual Studio installation found"
66+
exit 1
67+
}
68+
3169
- name: Setup MSBuild
3270
uses: microsoft/setup-msbuild@v2
3371

3472
- name: Build
3573
run: |
36-
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v142
74+
$toolset = '${{ steps.select_toolset.outputs.toolset }}'
75+
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=$toolset /p:XPDeprecationWarning=false
76+
77+
- name: Get app version
78+
id: get_version
79+
shell: pwsh
80+
run: |
81+
$versionFile = "metamod/version/appversion.h"
82+
if (-not (Test-Path $versionFile)) {
83+
Write-Error "Version file not found: $versionFile"
84+
exit 1
85+
}
86+
87+
$content = Get-Content $versionFile
88+
foreach ($line in $content) {
89+
if ($line -match '^\s*#define\s+APP_VERSION\s+"([^"]+)"') {
90+
$version = $matches[1]
91+
"version=$version" >> $env:GITHUB_OUTPUT
92+
Write-Host "Found version: $version"
93+
exit 0
94+
}
95+
}
96+
Write-Error "APP_VERSION not found in file"
97+
exit 1
98+
99+
- name: Show version
100+
run: echo "Version is ${{ steps.get_version.outputs.version }}"
101+
- name: Get rcedit from chocolatey
102+
shell: pwsh
103+
run: |
104+
choco install rcedit -y
37105
38106
- name: Move files
39107
run: |
40108
mkdir publish\debug
41109
mkdir publish\addons\metamod
42-
43110
move msvc\${{ env.buildRelease }}\metamod.dll publish\addons\metamod\metamod.dll
44111
move msvc\${{ env.buildRelease }}\metamod.pdb publish\debug\metamod.pdb
45112
113+
- name: Edit resources at windows binaries
114+
run: |
115+
rcedit ${{ github.workspace }}\publish\addons\metamod\metamod.dll --set-version-string ProductName "Metamod-R" --set-file-version "${{ steps.get_version.outputs.version }}" --set-product-version "${{ steps.get_version.outputs.version }}" --set-version-string FileDescription "Metamod-R is fully reworked fork of original Metamod-p by Jussi Kivilinna. Metamod allows running multiple mod-like plugin DLLs, to add functionality or change the behavior of the running HLDS game mod., Commit: $env:GITHUB_SHA" --set-version-string "Comments" "Commit: $env:GITHUB_SHA" --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 ReHLDS DevTeam"
116+
shell: "pwsh"
117+
118+
- name: Import PFX and sign
119+
if: github.event_name != 'pull_request'
120+
env:
121+
KEY_PFX_PASS: ${{ secrets.KEY_PFX_PASS }}
122+
run: |
123+
$pfxBase64 = "${{ secrets.KEY_PFX_B64 }}"
124+
[IO.File]::WriteAllBytes("${{ github.workspace }}\signing-cert.pfx", [Convert]::FromBase64String($pfxBase64))
125+
certutil -f -p "${{ secrets.KEY_PFX_PASS }}" -importPFX "${{ github.workspace }}\signing-cert.pfx"
126+
& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "Metamod-R" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha256 /fd sha256 /v ${{ github.workspace }}\publish\addons\metamod\metamod.dll
127+
Remove-Item -Recurse -Force "${{ github.workspace }}\signing-cert.pfx"
128+
shell: "pwsh"
46129
- name: Deploy artifacts
47130
uses: actions/upload-artifact@v4
48131
with:
@@ -71,6 +154,50 @@ jobs:
71154
git cmake rsync \
72155
g++ gcc
73156
157+
158+
- name: GPG Import
159+
run: |
160+
echo "${{ secrets.PUB_ASC }}" > "${{ secrets.PUB_ASC_FILE }}"
161+
echo "${{ secrets.KEY_ASC }}" > "${{ secrets.KEY_ASC_FILE }}"
162+
163+
# Import the public key
164+
gpg --batch --yes --import "${{ secrets.PUB_ASC_FILE }}"
165+
if [[ $? -ne 0 ]]; then
166+
echo "Error: Failed to import the public key"
167+
exit 1
168+
fi
169+
170+
# Import the private key
171+
gpg --batch --yes --import "${{ secrets.KEY_ASC_FILE }}"
172+
if [[ $? -ne 0 ]]; then
173+
echo "Error: Failed to import the private key"
174+
exit 2
175+
fi
176+
177+
# Extract the fingerprint of the imported public key
178+
GPG_LINUX_FINGERPRINT=$(gpg --list-keys --with-colons | grep '^fpr' | head -n 1 | cut -d: -f10)
179+
180+
# Check if the fingerprint was extracted
181+
if [[ -z "$GPG_LINUX_FINGERPRINT" ]]; then
182+
echo "Error: Failed to extract the fingerprint of the key"
183+
exit 3
184+
fi
185+
186+
# Set the trust level for the key
187+
echo "$GPG_LINUX_FINGERPRINT:6:" | gpg --batch --import-ownertrust
188+
if [ $? -ne 0 ]; then
189+
echo "Error: Failed to set trust for the key $GPG_LINUX_FINGERPRINT"
190+
exit 4
191+
fi
192+
193+
echo "Key $GPG_LINUX_FINGERPRINT successfully imported and trusted"
194+
gpg --list-keys
195+
196+
#export for global use
197+
echo "GPG_LINUX_FINGERPRINT=$GPG_LINUX_FINGERPRINT" >> $GITHUB_ENV
198+
shell: bash
199+
if: github.event_name != 'pull_request'
200+
74201
- name: Build using Intel GCC Compiler
75202
run: |
76203
rm -rf build && cmake -DCMAKE_BUILD_TYPE=COMPAT_GLIBC -B build && cmake --build build -j8
@@ -89,6 +216,7 @@ jobs:
89216
--include=plinfo.h \
90217
--exclude='*' metamod/src/ publish/sdk
91218
rsync metamod/extra/config.ini publish/addons/metamod
219+
rsync metamod/extra/plugins.ini publish/addons/metamod
92220
rsync -a metamod/extra/example/ publish/example_plugin
93221
rsync -a publish/sdk/ publish/example_plugin/include/metamod
94222
@@ -152,7 +280,29 @@ jobs:
152280
github.event.action == 'published' &&
153281
startsWith(github.ref, 'refs/tags/')
154282
run: |
283+
284+
# new runner, niw signs
285+
echo "${{ secrets.PUB_ASC }}" > "${{ secrets.PUB_ASC_FILE }}"
286+
echo "${{ secrets.KEY_ASC }}" > "${{ secrets.KEY_ASC_FILE }}"
287+
gpg --batch --yes --import "${{ secrets.PUB_ASC_FILE }}"
288+
gpg --batch --yes --import "${{ secrets.KEY_ASC_FILE }}"
289+
GPG_LINUX_FINGERPRINT=$(gpg --list-keys --with-colons | grep '^fpr' | head -n 1 | cut -d: -f10)
290+
echo "$GPG_LINUX_FINGERPRINT:6:" | gpg --batch --import-ownertrust
291+
echo "GPG_LINUX_FINGERPRINT=$GPG_LINUX_FINGERPRINT" >> $GITHUB_ENV
292+
293+
sign_file() {
294+
local file=$1
295+
gpg --batch --yes --detach-sign --armor -u "$GPG_LINUX_FINGERPRINT" "$file"
296+
if [ $? -ne 0 ]; then
297+
echo "Error: Failed to sign $file"
298+
exit 2
299+
fi
300+
echo "$file signed successfully."
301+
}
302+
303+
# Pack and sign final archive
155304
7z a -tzip metamod-bin-${{ env.APP_VERSION }}.zip addons/ example_plugin/ sdk/
305+
sign_file "metamod-bin-${{ env.APP_VERSION }}.zip"
156306
157307
- name: Publish artifacts
158308
uses: softprops/action-gh-release@v2

metamod/extra/plugins.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Default location: $gamedir/addons/metamod/plugins.ini, ie "cstrike/addons/metamod/plugins.ini".
2+
# Plugins are described in a file "plugins.ini" and each line describes a plugin to load:
3+
#
4+
# <platform> <filepath> [<description>]
5+
# Fields are whitespace delimited (tabs/spaces).
6+
#
7+
# linux path/to/plugin.so
8+
# win32 path/to/plugin.dll

metamod/msvc/PreBuild.bat

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,32 @@ set commitURL=
2020
set commitCount=0
2121
set branch_name=master
2222

23-
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
24-
set "YYYY=%dt:~0,4%"
25-
set "MM=%dt:~4,2%"
26-
set "DD=%dt:~6,2%"
27-
set "hour=%dt:~8,2%"
28-
set "min=%dt:~10,2%"
29-
set "sec=%dt:~12,2%"
23+
for /f "tokens=*" %%i in ('powershell -NoProfile -Command ^
24+
"$now = Get-Date; Write-Output ('{0:yyyy}|{0:MM}|{0:dd}|{0:HH}|{0:mm}|{0:ss}' -f $now)"') do (
25+
for /f "tokens=1-6 delims=|" %%a in ("%%i") do (
26+
set "YYYY=%%a"
27+
set "MM=%%b"
28+
set "DD=%%c"
29+
set "hour=%%d"
30+
set "min=%%e"
31+
set "sec=%%f"
32+
)
33+
)
34+
35+
echo YYYY=%YYYY%
36+
echo MM=%MM%
37+
echo DD=%DD%
38+
echo hour=%hour%
39+
echo min=%min%
40+
echo sec=%sec%
41+
42+
:: for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
43+
:: set "YYYY=%dt:~0,4%"
44+
:: set "MM=%dt:~4,2%"
45+
:: set "DD=%dt:~6,2%"
46+
:: set "hour=%dt:~8,2%"
47+
:: set "min=%dt:~10,2%"
48+
:: set "sec=%dt:~12,2%"
3049

3150
::
3251
:: Remove leading zero from MM (e.g 09 > 9)

metamod/msvc/metamod.vcxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup Label="ProjectConfigurations">
44
<ProjectConfiguration Include="Debug|Win32">
@@ -214,6 +214,7 @@
214214
</ItemGroup>
215215
<ItemGroup>
216216
<None Include="..\extra\config.ini" />
217+
<None Include="..\extra\plugins.ini" />
217218
<None Include="metamod.def" />
218219
</ItemGroup>
219220
<ItemGroup>

metamod/src/metamod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void metamod_startup()
5050
Q_snprintf(execFile, sizeof execFile, "%s/%s", g_config->directory(), EXEC_CFG);
5151

5252
META_CONS(" ");
53-
META_CONS(" Metamod-r version %s Copyright (c) 2016-2018 ReHLDS Team (rebuild of original Metamod by Will Day and Jussi Kivilinna)", APP_VERSION);
53+
META_CONS(" Metamod-r version %s Copyright (c) 2016-2025 ReHLDS Team (rebuild of original Metamod by Will Day and Jussi Kivilinna)", APP_VERSION);
5454
META_CONS(" Metamod-r comes with ABSOLUTELY NO WARRANTY; for details type `meta gpl'.");
5555
META_CONS(" This is free software, and you are welcome to redistribute it");
5656
META_CONS(" under certain conditions; type `meta gpl' for details.");

0 commit comments

Comments
 (0)