Skip to content

Fix build

Fix build #137

Workflow file for this run

name: Build Release
on:
push:
branches:
- master
- '[0-9]+.[0-9]+-dev'
env:
ARCH: x86,x86_64
DUMP_SYMS_VERSION: '2.3.7'
# Used for caching
# TODO: Handle this better so that we don't have to update this in lockstep with checkout-deps
MARIADB_CONNECTOR_C_VERSION: '3.4.9'
MARIADB_CONNECTOR_C_RELEASE: '3.4.9-sm.5'
MMSOURCE_VERSION: '1.12'
jobs:
build:
permissions:
contents: write
strategy:
matrix:
include:
- platform: windows
os: windows-latest
os_short: win
- platform: linux
os: ubuntu-latest
os_short: linux
container_image: ghcr.io/alliedmodders/build-containers/debian11-clang22:latest
fail-fast: false
name: ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
container:
image: ${{ matrix.container_image }}
steps:
- name: Checkout SourceMod
uses: actions/checkout@v7
with:
path: sourcemod
fetch-depth: 0
submodules: recursive
- name: Install Windows dependencies
if: startsWith(matrix.os, 'windows')
shell: pwsh
run: |
# Add DIA SDK bin directory to PATH for dump_syms
# vswhere.exe is pre-installed on GitHub Windows runners
$vsRoot = & vswhere -latest -property installationPath
$diaDir = Join-Path $vsRoot 'DIA SDK\bin'
$diaDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$toolsDir = New-Item -Path '_tools' -ItemType Directory -Force
$toolsDir.FullName | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
Push-Location $toolsDir
$dumpsymsUrl = "https://github.com/mozilla/dump_syms/releases/download/v${{ env.DUMP_SYMS_VERSION }}/dump_syms-x86_64-pc-windows-msvc.zip"
curl -sSL -o dump_syms.zip $dumpsymsUrl
Expand-Archive -Path dump_syms.zip -DestinationPath .
Remove-Item dump_syms.zip
# Flatten if extracted into a subdirectory
Get-ChildItem -Recurse -Filter 'dump_syms.exe' | Move-Item -Destination . -ErrorAction SilentlyContinue
Pop-Location
# Largely a workaround for issue where github.workspace doesn't match $GITHUB_WORKSPACE
# in containerized jobs. See https://github.com/actions/runner/issues/2058
- name: Resolve paths
id: path_helper
shell: bash
run: |
echo "dependencies=$GITHUB_WORKSPACE/dependencies" >> $GITHUB_OUTPUT
- name: Generate SDK list
id: sdk_list
shell: bash
run: |
sdk_list=()
for file in sourcemod/hl2sdk-manifests/manifests/*.json; do
sdk=$(basename "$file" .json)
if [[ $sdk == "mock" ]]; then
# We don't need to ship a build for the mock SDK
continue
fi
platform=$(jq -r '.platforms.${{ matrix.platform }}' "$file")
if [[ -z $platform || $platform == "null" || ${#platform[@]} -eq 0 ]]; then
continue
fi
source2=$(jq -r '.source2' "$file")
if [[ $source2 == "null" || $source2 == "true" ]]; then
continue
fi
sdk_list+=("$sdk")
done
echo "sdk_list=$(printf '%s\n' "${sdk_list[@]}" | jq --raw-input . | jq --slurp --compact-output .)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v6
env:
cache-name: hl2sdk-mariadb-connector-c-mmsource
with:
path: ${{ steps.path_helper.outputs.dependencies }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-mariadb${{ env.MARIADB_CONNECTOR_C_RELEASE }}-mmsource${{ env.MMSOURCE_VERSION }}-${{ join(fromJson(steps.sdk_list.outputs.sdk_list), '') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-mariadb${{ env.MARIADB_CONNECTOR_C_RELEASE }}-mmsource${{ env.MMSOURCE_VERSION }}-
${{ runner.os }}-build-${{ env.cache-name }}-mariadb${{ env.MARIADB_CONNECTOR_C_RELEASE }}-
- name: Install dependencies
shell: bash
env:
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
run: |
mkdir -p '${{ steps.path_helper.outputs.dependencies }}'
cd '${{ steps.path_helper.outputs.dependencies }}'
# Satisfy checkout-deps requirement for a "sourcemod" folder.
mkdir -p sourcemod
../sourcemod/tools/checkout-deps.sh -s ${{ join(fromJson(steps.sdk_list.outputs.sdk_list), ',') }}
if [ -z "$MAXMIND_LICENSE_KEY" ]; then
echo "::error::MAXMIND_LICENSE_KEY secret is not configured."
exit 1
fi
geotmpdir=$(mktemp -d)
geotar="$geotmpdir/GeoLite2-City.tar.gz"
curl -fsSL "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$MAXMIND_LICENSE_KEY&suffix=tar.gz" -o "$geotar"
tar -xzf "$geotar" -C "$geotmpdir"
geommdb=$(find "$geotmpdir" -type f -name 'GeoLite2-City.mmdb' | head -n 1)
if [ -z "$geommdb" ]; then
echo "::error::GeoLite2-City.mmdb not found in downloaded MaxMind archive."
exit 1
fi
cp "$geommdb" '${{ steps.path_helper.outputs.dependencies }}/GeoLite2-City.mmdb'
rm -rf "$geotmpdir"
- name: Build
working-directory: sourcemod
shell: bash
env:
BREAKPAD_SYMBOL_SERVER: ${{ vars.BREAKPAD_SYMBOL_SERVER }}
BREAKPAD_SYMBOL_SERVER_TOKEN: ${{ secrets.BREAKPAD_SYMBOL_SERVER_TOKEN }}
run: |
mkdir build
cd build
python3 ../configure.py \
--enable-optimize \
--breakpad-dump \
--symbol-files \
--sdks=${{ join(fromJson(steps.sdk_list.outputs.sdk_list), ',') }} \
--targets=${{ env.ARCH }} \
'--mms-path=${{ steps.path_helper.outputs.dependencies }}/mmsource-${{ env.MMSOURCE_VERSION }}' \
'--hl2sdk-root=${{ steps.path_helper.outputs.dependencies }}' \
'--mariadb-path=${{ steps.path_helper.outputs.dependencies }}/mariadb-connector-c-${{ env.MARIADB_CONNECTOR_C_VERSION }}-x86' \
'--mariadb64-path=${{ steps.path_helper.outputs.dependencies }}/mariadb-connector-c-${{ env.MARIADB_CONNECTOR_C_VERSION }}-x86_64'
ambuild
mkdir -p package/addons/sourcemod/configs/geoip
cp '${{ steps.path_helper.outputs.dependencies }}/GeoLite2-City.mmdb' package/addons/sourcemod/configs/geoip/GeoLite2-City.mmdb
- name: Package
id: package
working-directory: sourcemod/build/package
shell: bash
run: |
version_base=$(cat ../../product.version)
version_base=${version_base%-dev} # Ex. 1.12.0
version_rev=$(git rev-list --count HEAD)
version="${version_base}.${version_rev}"
expanded_version="${version_base}-git${version_rev}"
if [ "${{ matrix.platform}}" == "windows" ]; then
filename="sourcemod-${expanded_version}-${{ matrix.platform }}.zip"
7z a "$filename" addons cfg
content_type="application/zip"
else
filename="sourcemod-${expanded_version}-${{ matrix.platform }}.tar.gz"
tar zcf "$filename" addons cfg
content_type="application/gzip"
fi
echo "version=$version" >> $GITHUB_OUTPUT
echo "expanded_version=$expanded_version" >> $GITHUB_OUTPUT
echo "filename=$filename" >> $GITHUB_OUTPUT
echo "content_type=$content_type" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1.21.0
with:
# Windows and Linux packages will need to upload to the same release
allowUpdates: true
replacesArtifacts: false
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
# This gets overly large and meaningless with our existing release patterns
omitBody: true
artifacts: sourcemod/build/package/${{ steps.package.outputs.filename }}
artifactContentType: ${{ steps.package.outputs.content_type }}
artifactErrorsFailBuild: true
tag: ${{ steps.package.outputs.version }}
commit: ${{ github.sha }}
generateReleaseNotes: true
draft: false
prerelease: ${{ github.ref == 'refs/heads/master' }}
makeLatest: ${{ github.ref != 'refs/heads/master' }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Output PDBs
if: startsWith(matrix.os, 'windows')
shell: pwsh
id: output_pdbs
working-directory: sourcemod/build
run: |
$ErrorActionPreference = 'Stop'
$buildDir = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'sourcemod/build'
$outDir = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'pdbs'
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
Get-Content -LiteralPath (Join-Path -Path $buildDir -ChildPath 'pdblog.txt') |
ForEach-Object -Process {
$fullPdbPathInfo = (Get-Item -Path (Join-Path -Path $buildDir -ChildPath $_))
$baseName = $fullPdbPathInfo.BaseName
$dir = $fullPdbPathInfo.DirectoryName
$relDir = [System.IO.Path]::GetRelativePath($buildDir, $dir)
$destDir = Join-Path $outDir $relDir
New-Item -ItemType Directory -Force -Path $destDir | Out-Null
'.pdb', '.exe', '.dll' | ForEach-Object -Process {
$binPath = Join-Path $dir ($baseName + $_)
if (Test-Path $binPath) {
Copy-Item -Path $binPath -Destination $destDir
}
}
}
- name: Upload PDBs
if: startsWith(matrix.os, 'windows')
id: upload_pdbs
uses: actions/upload-artifact@v7
with:
name: pdbs
path: pdbs/*