Skip to content

Commit 2a1be20

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 3ee12cf + afc0989 commit 2a1be20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2154
-843
lines changed

.github/workflows/build.yml

Lines changed: 171 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ on:
44
push:
55
paths-ignore:
66
- '**.md'
7+
- '.github/**'
78

89
pull_request:
910
types: [opened, reopened, synchronize]
1011
release:
1112
types: [published]
13+
workflow_dispatch:
1214

1315
jobs:
1416
windows:
1517
name: 'Windows'
16-
runs-on: windows-2019
18+
runs-on: windows-2025
1719

1820
env:
1921
solution: 'msvc/ReGameDLL.sln'
@@ -23,19 +25,58 @@ jobs:
2325
buildTests: 'Tests'
2426

2527
steps:
28+
- name: Configure
29+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
30+
2631
- name: Checkout
2732
uses: actions/checkout@v4
2833
with:
2934
fetch-depth: 0
3035

3136
- name: Setup MSBuild
3237
uses: microsoft/setup-msbuild@v2
33-
with:
34-
vs-version: '16'
38+
39+
# TODO: add support of 141_xp toolchain at VS2022+
40+
# - name: Install v140, v141 and v142 toolsets
41+
# shell: cmd
42+
# run: |
43+
# "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify ^
44+
# --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" ^
45+
# --add Microsoft.VisualStudio.Component.WindowsXP ^
46+
# --add Microsoft.VisualStudio.Component.VC.v140 ^
47+
# --add Microsoft.VisualStudio.Component.VC.v140.x86.x64 ^
48+
# --add Microsoft.VisualStudio.Component.VC.v140.xp ^
49+
# --add Microsoft.VisualStudio.Component.VC.140.CRT ^
50+
# --add Microsoft.VisualStudio.Component.VC.v141 ^
51+
# --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 ^
52+
# --add Microsoft.VisualStudio.Component.VC.v141.xp ^
53+
# --add Microsoft.VisualStudio.Component.VC.v142 ^
54+
# --add Microsoft.VisualStudio.Component.VC.v142.x86.x64 ^
55+
# --quiet --norestart
56+
57+
- name: Select PlatformToolset
58+
id: select_toolset
59+
shell: pwsh
60+
run: |
61+
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
62+
$vs2019 = & $vswhere -products * -version "[16.0,17.0)" -property installationPath -latest
63+
$vs2022 = & $vswhere -products * -version "[17.0,)" -property installationPath -latest
64+
65+
if ($vs2019) {
66+
"toolset=v140_xp" >> $env:GITHUB_OUTPUT
67+
Write-Host "Selected v140_xp toolset"
68+
} elseif ($vs2022) {
69+
"toolset=v143" >> $env:GITHUB_OUTPUT
70+
Write-Host "Selected v143 toolset"
71+
} else {
72+
Write-Error "No suitable Visual Studio installation found"
73+
exit 1
74+
}
3575
3676
- name: Build and Run unittests
3777
run: |
38-
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildTests }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false
78+
$toolset = '${{ steps.select_toolset.outputs.toolset }}'
79+
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildTests }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=$toolset /p:XPDeprecationWarning=false
3980
.\"msvc\Tests\mp.exe"
4081
If ($LASTEXITCODE -ne 0 -And
4182
$LASTEXITCODE -ne 3)
@@ -44,8 +85,13 @@ jobs:
4485

4586
- name: Build
4687
run: |
47-
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false
48-
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildReleasePlay }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false
88+
$toolset = '${{ steps.select_toolset.outputs.toolset }}'
89+
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=$toolset /p:XPDeprecationWarning=false
90+
msbuild ${{ env.solution }} -p:Configuration="${{ env.buildReleasePlay }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=$toolset /p:XPDeprecationWarning=false
91+
- name: Get rcedit from chocolatey
92+
shell: pwsh
93+
run: |
94+
choco install rcedit -y
4995
5096
- name: Move files
5197
run: |
@@ -56,6 +102,49 @@ jobs:
56102
move msvc\${{ env.buildRelease }}\mp.dll publish\bin\win32\cstrike\dlls\mp.dll
57103
move msvc\${{ env.buildRelease }}\mp.pdb publish\debug\mp.pdb
58104
105+
- name: Get app version
106+
id: get_version
107+
shell: pwsh
108+
run: |
109+
$versionFile = "regamedll/version/appversion.h"
110+
if (-not (Test-Path $versionFile)) {
111+
Write-Error "Version file not found: $versionFile"
112+
exit 1
113+
}
114+
115+
$content = Get-Content $versionFile
116+
foreach ($line in $content) {
117+
if ($line -match '^\s*#define\s+APP_VERSION\s+"([^"]+)"') {
118+
$version = $matches[1]
119+
"version=$version" >> $env:GITHUB_OUTPUT
120+
Write-Host "Found version: $version"
121+
exit 0
122+
}
123+
}
124+
Write-Error "APP_VERSION not found in file"
125+
exit 1
126+
127+
- name: Show version
128+
run: echo "Version is ${{ steps.get_version.outputs.version }}"
129+
130+
- name: Import PFX and sign
131+
if: github.event_name != 'pull_request'
132+
env:
133+
KEY_PFX_PASS: ${{ secrets.KEY_PFX_PASS }}
134+
# https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md
135+
run: |
136+
$pfxBase64 = "${{ secrets.KEY_PFX_B64 }}"
137+
[IO.File]::WriteAllBytes("${{ github.workspace }}\signing-cert.pfx", [Convert]::FromBase64String($pfxBase64))
138+
certutil -f -p "${{ secrets.KEY_PFX_PASS }}" -importPFX "${{ github.workspace }}\signing-cert.pfx"
139+
& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "Regamedll_CS is a result of reverse engineering of original library mod HLDS (build 6153beta) using DWARF debug info embedded into linux version of HLDS, cs.so" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha256 /fd sha256 /v ${{ github.workspace }}\publish\bin\win32\cstrike\dlls\mp.dll
140+
Remove-Item -Recurse -Force "${{ github.workspace }}\signing-cert.pfx"
141+
shell: "pwsh"
142+
143+
- name: Edit resources at windows binaries
144+
run: |
145+
rcedit ${{ github.workspace }}\publish\bin\win32\cstrike\dlls\mp.dll --set-version-string ProductName "Regamedll_CS - mp.dll" --set-file-version "${{ steps.get_version.outputs.version }}" --set-product-version "${{ steps.get_version.outputs.version }}" --set-version-string FileDescription "Regamedll_CS (mp.dll) - provide more stable (than official) version of Counter-Strike game with extended API for mods and plugins, Commit: $env:GITHUB_SHA" --set-version-string "Comments" "Regamedll_CS is a result of reverse engineering of original library mod HLDS (build 6153beta) using DWARF debug info embedded into linux version of HLDS, cs.so. Commit: $env:GITHUB_SHA" --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 Valve, ReHLDS DevTeam" --set-icon regamedll/msvc/icon.ico
146+
shell: "pwsh"
147+
59148
- name: Deploy artifacts
60149
uses: actions/upload-artifact@v4
61150
with:
@@ -104,11 +193,6 @@ jobs:
104193
container: debian:11-slim
105194

106195
steps:
107-
- name: Checkout
108-
uses: actions/checkout@v4
109-
with:
110-
fetch-depth: 0
111-
112196
- name: Install dependencies
113197
run: |
114198
dpkg --add-architecture i386
@@ -120,6 +204,58 @@ jobs:
120204
git cmake rsync \
121205
g++ gcc
122206
207+
- name: Configure
208+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
209+
210+
- name: Checkout
211+
uses: actions/checkout@v4
212+
with:
213+
submodules: recursive
214+
fetch-depth: 0
215+
216+
- name: GPG Import
217+
run: |
218+
echo "${{ secrets.PUB_ASC }}" > "${{ secrets.PUB_ASC_FILE }}"
219+
echo "${{ secrets.KEY_ASC }}" > "${{ secrets.KEY_ASC_FILE }}"
220+
221+
# Import the public key
222+
gpg --batch --yes --import "${{ secrets.PUB_ASC_FILE }}"
223+
if [[ $? -ne 0 ]]; then
224+
echo "Error: Failed to import the public key"
225+
exit 1
226+
fi
227+
228+
# Import the private key
229+
gpg --batch --yes --import "${{ secrets.KEY_ASC_FILE }}"
230+
if [[ $? -ne 0 ]]; then
231+
echo "Error: Failed to import the private key"
232+
exit 2
233+
fi
234+
235+
# Extract the fingerprint of the imported public key
236+
GPG_LINUX_FINGERPRINT=$(gpg --list-keys --with-colons | grep '^fpr' | head -n 1 | cut -d: -f10)
237+
238+
# Check if the fingerprint was extracted
239+
if [[ -z "$GPG_LINUX_FINGERPRINT" ]]; then
240+
echo "Error: Failed to extract the fingerprint of the key"
241+
exit 3
242+
fi
243+
244+
# Set the trust level for the key
245+
echo "$GPG_LINUX_FINGERPRINT:6:" | gpg --batch --import-ownertrust
246+
if [ $? -ne 0 ]; then
247+
echo "Error: Failed to set trust for the key $GPG_LINUX_FINGERPRINT"
248+
exit 4
249+
fi
250+
251+
echo "Key $GPG_LINUX_FINGERPRINT successfully imported and trusted"
252+
gpg --list-keys
253+
254+
#export for global use
255+
echo "GPG_LINUX_FINGERPRINT=$GPG_LINUX_FINGERPRINT" >> $GITHUB_ENV
256+
shell: bash
257+
if: github.event_name != 'pull_request'
258+
123259
- name: Build and Run unittests
124260
run: |
125261
rm -rf build && CC=gcc CXX=g++ cmake -DCMAKE_BUILD_TYPE=Unittests -B build && cmake --build build -j8
@@ -216,7 +352,29 @@ jobs:
216352
run: |
217353
rsync -a dist/ bin/win32/cstrike
218354
rsync -a dist/ bin/linux32/cstrike
355+
356+
# new runner, niw signs
357+
echo "${{ secrets.PUB_ASC }}" > "${{ secrets.PUB_ASC_FILE }}"
358+
echo "${{ secrets.KEY_ASC }}" > "${{ secrets.KEY_ASC_FILE }}"
359+
gpg --batch --yes --import "${{ secrets.PUB_ASC_FILE }}"
360+
gpg --batch --yes --import "${{ secrets.KEY_ASC_FILE }}"
361+
GPG_LINUX_FINGERPRINT=$(gpg --list-keys --with-colons | grep '^fpr' | head -n 1 | cut -d: -f10)
362+
echo "$GPG_LINUX_FINGERPRINT:6:" | gpg --batch --import-ownertrust
363+
echo "GPG_LINUX_FINGERPRINT=$GPG_LINUX_FINGERPRINT" >> $GITHUB_ENV
364+
365+
sign_file() {
366+
local file=$1
367+
gpg --batch --yes --detach-sign --armor -u "$GPG_LINUX_FINGERPRINT" "$file"
368+
if [ $? -ne 0 ]; then
369+
echo "Error: Failed to sign $file"
370+
exit 2
371+
fi
372+
echo "$file signed successfully."
373+
}
374+
375+
# Pack and sign final archive
219376
7z a -tzip regamedll-bin-${{ env.APP_VERSION }}.zip bin/ cssdk/
377+
sign_file "regamedll-bin-${{ env.APP_VERSION }}.zip"
220378
221379
- name: Publish artifacts
222380
uses: softprops/action-gh-release@v2
@@ -227,6 +385,8 @@ jobs:
227385
with:
228386
files: |
229387
*.zip
388+
*.7z
389+
*.asc
230390
env:
231391
GITHUB_TOKEN: ${{ secrets.API_TOKEN }}
232392

0 commit comments

Comments
 (0)