Rework the CI to build inside the valve sniper sdk container thing (#56)

This commit is contained in:
rtldg 2025-11-22 12:48:24 +00:00 committed by GitHub
parent 9aa1fb0474
commit 736afc5d1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 60 additions and 40 deletions

24
.github/workflows/build.sh vendored Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
set -euxo pipefail
cd "$(dirname $0)/../.."
if [[ $PLATFORM == Linux* ]]; then
$CC --version
$CXX --version
apt install -y python3-pip
# buildbot/generate_header.py is ran by ambuild and we want git to not fail due to user-perms (because docker)
git config --global --add safe.directory $PWD
else
python -m pip install --upgrade pip setuptools wheel
fi
python -m pip install $CACHE_PATH/ambuild
mkdir build
cd build
python ../configure.py --enable-auto-versioning --enable-optimize --sdks="$SDKS" --mms-path="$CACHE_PATH/metamod-source" --hl2sdk-root="$CACHE_PATH" --sm-path="$CACHE_PATH/sourcemod"
ambuild

View File

@ -11,9 +11,10 @@ jobs:
build: build:
strategy: strategy:
matrix: matrix:
os: [ubuntu-22.04, windows-2022] python-version: ['3.14']
os: [ubuntu-latest, windows-2022]
include: include:
- os: ubuntu-22.04 - os: ubuntu-latest
cc: clang-11 cc: clang-11
cxx: clang++-11 cxx: clang++-11
- os: windows-2022 - os: windows-2022
@ -37,26 +38,13 @@ jobs:
SDKS_VAR="${{env.SDKS}}" SDKS_VAR="${{env.SDKS}}"
# This will be used in our cache key # This will be used in our cache key
echo "SDKS_KEY=${SDKS_VAR//[[:blank:]]/}" >> $GITHUB_ENV echo "SDKS_KEY=${SDKS_VAR//[[:blank:]]/}" >> $GITHUB_ENV
- name: Linux dependencies
if: startsWith(runner.os, 'Linux')
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
gcc-multilib g++-multilib libstdc++6 lib32stdc++6 \
libc6-dev libc6-dev-i386 linux-libc-dev \
linux-libc-dev:i386 lib32z1-dev ${{ matrix.cc }}
- uses: actions/setup-python@v6 - uses: actions/setup-python@v6
name: Setup Python 3.9 if: startsWith(matrix.os, 'windows-')
name: Setup Python ${{ matrix.python-version }}
with: with:
python-version: 3.9 python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
- uses: actions/checkout@v4 - uses: actions/checkout@v4
name: Repository checkout name: Repository checkout
with: with:
@ -105,31 +93,38 @@ jobs:
# But maybe others aren't (also probably unnecessary because git actions but paranoia) # But maybe others aren't (also probably unnecessary because git actions but paranoia)
git config --global advice.detachedHead true git config --global advice.detachedHead true
- name: Setup AMBuild
shell: bash
run: |
cd "${{ env.CACHE_PATH }}"
python -m pip install ./ambuild
- name: Select clang compiler
if: startsWith(runner.os, 'Linux')
run: |
echo "CC=${{ matrix.cc }}" >> $GITHUB_ENV
echo "CXX=${{ matrix.cxx }}" >> $GITHUB_ENV
${{ matrix.cc }} --version
${{ matrix.cxx }} --version
- name: Build - name: Build
shell: bash shell: bash
working-directory: extension working-directory: extension
run: | run: |
mkdir build export PLATFORM="${{ runner.os }}"
cd build
python ../configure.py --enable-auto-versioning --enable-optimize --sdks="${{ env.SDKS }}" --mms-path="${{ env.CACHE_PATH }}/metamod-source" --hl2sdk-root="${{ env.CACHE_PATH }}" --sm-path="${{ env.CACHE_PATH }}/sourcemod"
ambuild
PLATFORM="${{ runner.os }}" if [[ $PLATFORM == Linux* ]]; then
FILENAME="$(cat ./includes/filename_versioning.txt)" # docker instead of podman because:
# - we don't need a job to `sudo apt install podman`
# - `sudo apt install -y python3-pip` didn't work inside podman for me?
docker run \
-e PLATFORM="$PLATFORM" \
-e PROJECT=${{ env.PROJECT }} \
-e SDKS="${{ env.SDKS }}" \
-e MMSOURCE_VERSION=${{ env.MMSOURCE_VERSION }} \
-e SOURCEMOD_VERSION=${{ env.MMSOURCE_SOURCEMOD_VERSION }} \
-e CACHE_PATH=${{ env.CACHE_PATH }} \
-e SDKS_KEY=${{ env.SDKS_KEY }} \
-e CC=${{ matrix.cc }} \
-e CXX=${{ matrix.cxx }} \
--mount type=bind,source=${{ env.CACHE_PATH }},target=${{ env.CACHE_PATH }} \
--mount type=bind,source=$PWD,target=$PWD \
"registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest" \
"$PWD/.github/workflows/build.sh"
# need to fix the owner because docker root-ed stuff?
sudo chown -R $USER .
else
bash ./.github/workflows/build.sh
fi
FILENAME="$(cat build/includes/filename_versioning.txt)"
ZIP_FILENAME="${{ env.PROJECT }}-${FILENAME}-${PLATFORM,}.zip" ZIP_FILENAME="${{ env.PROJECT }}-${FILENAME}-${PLATFORM,}.zip"
echo "ZIP_FILENAME=${ZIP_FILENAME}" >> $GITHUB_ENV echo "ZIP_FILENAME=${ZIP_FILENAME}" >> $GITHUB_ENV

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ build
Containerfile Containerfile
.venv .venv
safetyhook safetyhook
.env

View File

@ -20,7 +20,7 @@ parser.options.add_argument('--enable-auto-versioning', action='store_false', de
default=True, help='Enables the auto versioning script') default=True, help='Enables the auto versioning script')
parser.options.add_argument('-s', '--sdks', default='all', dest='sdks', parser.options.add_argument('-s', '--sdks', default='all', dest='sdks',
help='Build against specified SDKs; valid args are "all", "present", or ' help='Build against specified SDKs; valid args are "all", "present", or '
'space-delimited list of engine names (default: %default)') 'space-delimited list of engine names (default: %(default)s)')
parser.options.add_argument('--targets', type=str, dest='targets', default=None, parser.options.add_argument('--targets', type=str, dest='targets', default=None,
help="Override the target architecture (use commas to separate multiple targets).") help="Override the target architecture (use commas to separate multiple targets).")
parser.Configure() parser.Configure()