Skip to content

Commit 77c3ab5

Browse files
authored
Merge branch 'master' into Hooks_Materialize_CheckRespawn
2 parents 59c8447 + 1d18ddb commit 77c3ab5

31 files changed

Lines changed: 1330 additions & 125 deletions

.github/workflows/build.yml

Lines changed: 186 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,81 @@ on:
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

1416
jobs:
1517
windows:
1618
name: 'Windows'
17-
runs-on: windows-2019
19+
runs-on: windows-2025
1820

1921
env:
2022
solution: 'msvc/reapi.sln'
2123
buildPlatform: 'Win32'
2224
buildRelease: 'Release'
2325

2426
steps:
27+
- name: Configure
28+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
29+
2530
- name: Checkout
26-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
2732
with:
2833
fetch-depth: 0
2934

3035
- name: Setup MSBuild
31-
uses: microsoft/setup-msbuild@v1.1.3
32-
with:
33-
vs-version: '16.8'
36+
uses: microsoft/setup-msbuild@v2
37+
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
3455

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+
}
3574
- name: Build
3675
run: |
37-
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
3883
3984
- name: Move files
4085
run: |
@@ -44,31 +89,128 @@ jobs:
4489
move msvc\${{ env.buildRelease }}\reapi_amxx.dll publish\addons\amxmodx\modules\reapi_amxx.dll
4590
move msvc\${{ env.buildRelease }}\reapi_amxx.pdb publish\debug\reapi_amxx.pdb
4691
92+
- name: Get app version
93+
id: get_version
94+
shell: pwsh
95+
run: |
96+
$versionFile = "reapi/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: Edit resources at windows binaries
118+
run: |
119+
rcedit ${{ github.workspace }}\publish\addons\amxmodx\modules\reapi_amxx.dll --set-version-string CompanyName "ReHLDS Dev Team" --set-version-string LegalCopyright "Copyright 2025 ReHLDS DevTeam" --set-icon reapi/msvc/icon.ico
120+
shell: "pwsh"
121+
122+
- name: Import PFX and sign
123+
if: github.event_name != 'pull_request'
124+
env:
125+
KEY_PFX_PASS: ${{ secrets.KEY_PFX_PASS }}
126+
# https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md
127+
run: |
128+
$pfxBase64 = "${{ secrets.KEY_PFX_B64 }}"
129+
[IO.File]::WriteAllBytes("${{ github.workspace }}\signing-cert.pfx", [Convert]::FromBase64String($pfxBase64))
130+
certutil -f -p "${{ secrets.KEY_PFX_PASS }}" -importPFX "${{ github.workspace }}\signing-cert.pfx"
131+
& '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
132+
Remove-Item -Recurse -Force "${{ github.workspace }}\signing-cert.pfx"
133+
shell: "pwsh"
134+
47135
- name: Deploy artifacts
48-
uses: actions/upload-artifact@v3.1.1
136+
uses: actions/upload-artifact@v4
49137
with:
50138
name: win32
51139
path: publish/*
52140

53141
linux:
54142
name: 'Linux'
55-
runs-on: ubuntu-latest
56-
container: s1lentq/linux86buildtools:latest
143+
runs-on: ubuntu-24.04
144+
container: debian:11-slim
57145
outputs:
58146
app-version: ${{ steps.app-version.outputs.version }}
59147

60-
env:
61-
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
62-
63148
steps:
149+
- name: Check dependencies
150+
run: |
151+
dpkg --add-architecture i386
152+
apt-get update
153+
apt-get install -y \
154+
gcc-multilib g++-multilib \
155+
build-essential \
156+
libc6-dev libc6-dev-i386 \
157+
git cmake rsync \
158+
g++ gcc
159+
160+
- name: Configure
161+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
162+
64163
- name: Checkout
65-
uses: actions/checkout@v3
164+
uses: actions/checkout@v4
66165
with:
67166
fetch-depth: 0
68167

69-
- name: Build using Intel C++ Compiler 19.0
168+
- name: GPG Import
169+
run: |
170+
echo "${{ secrets.PUB_ASC }}" > "${{ secrets.PUB_ASC_FILE }}"
171+
echo "${{ secrets.KEY_ASC }}" > "${{ secrets.KEY_ASC_FILE }}"
172+
173+
# Import the public key
174+
gpg --batch --yes --import "${{ secrets.PUB_ASC_FILE }}"
175+
if [[ $? -ne 0 ]]; then
176+
echo "Error: Failed to import the public key"
177+
exit 1
178+
fi
179+
180+
# Import the private key
181+
gpg --batch --yes --import "${{ secrets.KEY_ASC_FILE }}"
182+
if [[ $? -ne 0 ]]; then
183+
echo "Error: Failed to import the private key"
184+
exit 2
185+
fi
186+
187+
# Extract the fingerprint of the imported public key
188+
GPG_LINUX_FINGERPRINT=$(gpg --list-keys --with-colons | grep '^fpr' | head -n 1 | cut -d: -f10)
189+
190+
# Check if the fingerprint was extracted
191+
if [[ -z "$GPG_LINUX_FINGERPRINT" ]]; then
192+
echo "Error: Failed to extract the fingerprint of the key"
193+
exit 3
194+
fi
195+
196+
# Set the trust level for the key
197+
echo "$GPG_LINUX_FINGERPRINT:6:" | gpg --batch --import-ownertrust
198+
if [ $? -ne 0 ]; then
199+
echo "Error: Failed to set trust for the key $GPG_LINUX_FINGERPRINT"
200+
exit 4
201+
fi
202+
203+
echo "Key $GPG_LINUX_FINGERPRINT successfully imported and trusted"
204+
gpg --list-keys
205+
206+
#export for global use
207+
echo "GPG_LINUX_FINGERPRINT=$GPG_LINUX_FINGERPRINT" >> $GITHUB_ENV
208+
shell: bash
209+
if: github.event_name != 'pull_request'
210+
211+
- name: Build
70212
run: |
71-
rm -rf build && CC=icc CXX=icpc cmake -B build && cmake --build build -j8
213+
rm -rf build && CC=gcc CXX=g++ cmake -B build && cmake --build build -j8
72214
73215
- name: Reading appversion.h
74216
id: app-version
@@ -80,6 +222,7 @@ jobs:
80222
else
81223
# Remove quotes
82224
APP_VERSION=$(echo $APP_VERSION | xargs)
225+
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV
83226
fi
84227
fi
85228
echo "version=${APP_VERSION}" >> "$GITHUB_OUTPUT"
@@ -107,7 +250,7 @@ jobs:
107250
shell: bash
108251

109252
- name: Deploy artifacts
110-
uses: actions/upload-artifact@v3.1.1
253+
uses: actions/upload-artifact@v4
111254
id: upload-job
112255
with:
113256
name: linux32
@@ -120,12 +263,12 @@ jobs:
120263

121264
steps:
122265
- name: Deploying linux artifacts
123-
uses: actions/download-artifact@v3
266+
uses: actions/download-artifact@v4
124267
with:
125268
name: linux32
126269

127270
- name: Deploying windows artifacts
128-
uses: actions/download-artifact@v3
271+
uses: actions/download-artifact@v4
129272
with:
130273
name: win32
131274

@@ -136,16 +279,40 @@ jobs:
136279
github.event.action == 'published' &&
137280
startsWith(github.ref, 'refs/tags/')
138281
run: |
282+
283+
# new runner, niw signs
284+
echo "${{ secrets.PUB_ASC }}" > "${{ secrets.PUB_ASC_FILE }}"
285+
echo "${{ secrets.KEY_ASC }}" > "${{ secrets.KEY_ASC_FILE }}"
286+
gpg --batch --yes --import "${{ secrets.PUB_ASC_FILE }}"
287+
gpg --batch --yes --import "${{ secrets.KEY_ASC_FILE }}"
288+
GPG_LINUX_FINGERPRINT=$(gpg --list-keys --with-colons | grep '^fpr' | head -n 1 | cut -d: -f10)
289+
echo "$GPG_LINUX_FINGERPRINT:6:" | gpg --batch --import-ownertrust
290+
echo "GPG_LINUX_FINGERPRINT=$GPG_LINUX_FINGERPRINT" >> $GITHUB_ENV
291+
292+
sign_file() {
293+
local file=$1
294+
gpg --batch --yes --detach-sign --armor -u "$GPG_LINUX_FINGERPRINT" "$file"
295+
if [ $? -ne 0 ]; then
296+
echo "Error: Failed to sign $file"
297+
exit 2
298+
fi
299+
echo "$file signed successfully."
300+
}
301+
302+
# Pack and sign final archive
139303
7z a -tzip reapi-bin-${{ needs.linux.outputs.app-version }}.zip addons/
304+
sign_file "reapi-bin-${{ env.APP_VERSION }}.zip"
140305
141306
- name: Publish artifacts
142-
uses: softprops/action-gh-release@v1
307+
uses: softprops/action-gh-release@v2
143308
id: publish-job
144309
if: |
145310
startsWith(github.ref, 'refs/tags/') &&
146311
steps.packaging-job.outcome == 'success'
147312
with:
148313
files: |
149314
*.zip
315+
*.7z
316+
*.asc
150317
env:
151318
GITHUB_TOKEN: ${{ secrets.API_TOKEN }}

0 commit comments

Comments
 (0)