55 branches : [master]
66 paths-ignore :
77 - ' **.md'
8+ - ' .github/**'
89
910 pull_request :
1011 types : [opened, reopened, synchronize]
1112 release :
1213 types : [published]
14+ workflow_dispatch :
1315
1416jobs :
1517 windows :
1618 name : ' Windows'
17- runs-on : windows-2019
19+ runs-on : windows-2025
1820
1921 env :
2022 solution : ' msvc/reapi.sln'
@@ -32,12 +34,52 @@ jobs:
3234
3335 - name : Setup MSBuild
3436 uses : microsoft/setup-msbuild@v2
35- with :
36- vs-version : ' 16'
3737
38+ # TODO: add support of 141_xp toolchain at VS2022+
39+ # - name: Install v140, v141 and v142 toolsets
40+ # shell: cmd
41+ # run: |
42+ # "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify ^
43+ # --installPath "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" ^
44+ # --add Microsoft.VisualStudio.Component.WindowsXP ^
45+ # --add Microsoft.VisualStudio.Component.VC.v140 ^
46+ # --add Microsoft.VisualStudio.Component.VC.v140.x86.x64 ^
47+ # --add Microsoft.VisualStudio.Component.VC.v140.xp ^
48+ # --add Microsoft.VisualStudio.Component.VC.140.CRT ^
49+ # --add Microsoft.VisualStudio.Component.VC.v141 ^
50+ # --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 ^
51+ # --add Microsoft.VisualStudio.Component.VC.v141.xp ^
52+ # --add Microsoft.VisualStudio.Component.VC.v142 ^
53+ # --add Microsoft.VisualStudio.Component.VC.v142.x86.x64 ^
54+ # --quiet --norestart
55+
56+ - name : Select PlatformToolset
57+ id : select_toolset
58+ shell : pwsh
59+ run : |
60+ $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
61+ $vs2019 = & $vswhere -products * -version "[16.0,17.0)" -property installationPath -latest
62+ $vs2022 = & $vswhere -products * -version "[17.0,)" -property installationPath -latest
63+
64+ if ($vs2019) {
65+ "toolset=v140_xp" >> $env:GITHUB_OUTPUT
66+ Write-Host "Selected v140_xp toolset"
67+ } elseif ($vs2022) {
68+ "toolset=v143" >> $env:GITHUB_OUTPUT
69+ Write-Host "Selected v143 toolset"
70+ } else {
71+ Write-Error "No suitable Visual Studio installation found"
72+ exit 1
73+ }
3874 - name : Build
3975 run : |
40- msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v140_xp /p:XPDeprecationWarning=false
76+ $toolset = '${{ steps.select_toolset.outputs.toolset }}'
77+ msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=$toolset /p:XPDeprecationWarning=false
78+
79+ # - name: Get rcedit from chocolatey
80+ # shell: pwsh
81+ # run: |
82+ # choco install rcedit -y
4183
4284 - name : Move files
4385 run : |
4789 move msvc\${{ env.buildRelease }}\reapi_amxx.dll publish\addons\amxmodx\modules\reapi_amxx.dll
4890 move msvc\${{ env.buildRelease }}\reapi_amxx.pdb publish\debug\reapi_amxx.pdb
4991
92+ - name : Get app version
93+ id : get_version
94+ shell : pwsh
95+ run : |
96+ $versionFile = "rehlds/version/appversion.h"
97+ if (-not (Test-Path $versionFile)) {
98+ Write-Error "Version file not found: $versionFile"
99+ exit 1
100+ }
101+
102+ $content = Get-Content $versionFile
103+ foreach ($line in $content) {
104+ if ($line -match '^\s*#define\s+APP_VERSION\s+"([^"]+)"') {
105+ $version = $matches[1]
106+ "version=$version" >> $env:GITHUB_OUTPUT
107+ Write-Host "Found version: $version"
108+ exit 0
109+ }
110+ }
111+ Write-Error "APP_VERSION not found in file"
112+ exit 1
113+
114+ - name : Show version
115+ run : echo "Version is ${{ steps.get_version.outputs.version }}"
116+
117+ - name : Import PFX and sign
118+ if : github.event_name != 'pull_request'
119+ env :
120+ KEY_PFX_PASS : ${{ secrets.KEY_PFX_PASS }}
121+ # https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md
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.26100.0\x86\signtool.exe' sign /a /f "${{ github.workspace }}\signing-cert.pfx" /p $env:KEY_PFX_PASS /d "ReAPI - AMX Mod X module, using API regamedll & rehlds" /du "https://rehlds.dev/" /tr "http://timestamp.digicert.com" /td sha256 /fd sha256 /v ${{ github.workspace }}\publish\addons\amxmodx\modules\reapi_amxx.dll
127+ Remove-Item -Recurse -Force "${{ github.workspace }}\signing-cert.pfx"
128+ shell : " pwsh"
129+
50130 - name : Deploy artifacts
51131 uses : actions/upload-artifact@v4
52132 with :
@@ -80,6 +160,49 @@ jobs:
80160 with :
81161 fetch-depth : 0
82162
163+ - name : GPG Import
164+ run : |
165+ echo "${{ secrets.PUB_ASC }}" > "${{ secrets.PUB_ASC_FILE }}"
166+ echo "${{ secrets.KEY_ASC }}" > "${{ secrets.KEY_ASC_FILE }}"
167+
168+ # Import the public key
169+ gpg --batch --yes --import "${{ secrets.PUB_ASC_FILE }}"
170+ if [[ $? -ne 0 ]]; then
171+ echo "Error: Failed to import the public key"
172+ exit 1
173+ fi
174+
175+ # Import the private key
176+ gpg --batch --yes --import "${{ secrets.KEY_ASC_FILE }}"
177+ if [[ $? -ne 0 ]]; then
178+ echo "Error: Failed to import the private key"
179+ exit 2
180+ fi
181+
182+ # Extract the fingerprint of the imported public key
183+ GPG_LINUX_FINGERPRINT=$(gpg --list-keys --with-colons | grep '^fpr' | head -n 1 | cut -d: -f10)
184+
185+ # Check if the fingerprint was extracted
186+ if [[ -z "$GPG_LINUX_FINGERPRINT" ]]; then
187+ echo "Error: Failed to extract the fingerprint of the key"
188+ exit 3
189+ fi
190+
191+ # Set the trust level for the key
192+ echo "$GPG_LINUX_FINGERPRINT:6:" | gpg --batch --import-ownertrust
193+ if [ $? -ne 0 ]; then
194+ echo "Error: Failed to set trust for the key $GPG_LINUX_FINGERPRINT"
195+ exit 4
196+ fi
197+
198+ echo "Key $GPG_LINUX_FINGERPRINT successfully imported and trusted"
199+ gpg --list-keys
200+
201+ #export for global use
202+ echo "GPG_LINUX_FINGERPRINT=$GPG_LINUX_FINGERPRINT" >> $GITHUB_ENV
203+ shell : bash
204+ if : github.event_name != 'pull_request'
205+
83206 - name : Build
84207 run : |
85208 rm -rf build && CC=gcc CXX=g++ cmake -B build && cmake --build build -j8
94217 else
95218 # Remove quotes
96219 APP_VERSION=$(echo $APP_VERSION | xargs)
220+ echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV
97221 fi
98222 fi
99223 echo "version=${APP_VERSION}" >> "$GITHUB_OUTPUT"
@@ -150,7 +274,29 @@ jobs:
150274 github.event.action == 'published' &&
151275 startsWith(github.ref, 'refs/tags/')
152276 run : |
277+
278+ # new runner, niw signs
279+ echo "${{ secrets.PUB_ASC }}" > "${{ secrets.PUB_ASC_FILE }}"
280+ echo "${{ secrets.KEY_ASC }}" > "${{ secrets.KEY_ASC_FILE }}"
281+ gpg --batch --yes --import "${{ secrets.PUB_ASC_FILE }}"
282+ gpg --batch --yes --import "${{ secrets.KEY_ASC_FILE }}"
283+ GPG_LINUX_FINGERPRINT=$(gpg --list-keys --with-colons | grep '^fpr' | head -n 1 | cut -d: -f10)
284+ echo "$GPG_LINUX_FINGERPRINT:6:" | gpg --batch --import-ownertrust
285+ echo "GPG_LINUX_FINGERPRINT=$GPG_LINUX_FINGERPRINT" >> $GITHUB_ENV
286+
287+ sign_file() {
288+ local file=$1
289+ gpg --batch --yes --detach-sign --armor -u "$GPG_LINUX_FINGERPRINT" "$file"
290+ if [ $? -ne 0 ]; then
291+ echo "Error: Failed to sign $file"
292+ exit 2
293+ fi
294+ echo "$file signed successfully."
295+ }
296+
297+ # Pack and sign final archive
153298 7z a -tzip reapi-bin-${{ needs.linux.outputs.app-version }}.zip addons/
299+ sign_file "reapi-bin-${{ env.APP_VERSION }}.zip"
154300
155301 - name : Publish artifacts
156302 uses : softprops/action-gh-release@v2
0 commit comments