1111 types : [opened, reopened, synchronize]
1212 release :
1313 types : [published]
14+ workflow_dispatch :
1415
1516jobs :
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
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
0 commit comments