@@ -21,25 +21,41 @@ jobs:
2121 strategy :
2222 matrix :
2323 platform : [
24- { os: ubuntu-20.04, cc: clang-8, cxx: clang++-8, release: true },
25- { os: ubuntu-latest, cc: clang, cxx: clang++, release: false },
26- { os: windows-2019, cc: msvc, release: true },
27- { os: windows-latest, cc: msvc, release: false }
24+ { name: ubuntu-20.04, os: ubuntu-latest, containerImage: 'ubuntu: 20.04' , cc: clang-8, cxx: clang++-8, release: true },
25+ { name: ubuntu-latest, os: ubuntu-latest, cc: clang, cxx: clang++, release: false },
26+ { name: windows-2019, os: windows-2019, cc: msvc, release: true },
27+ { name: windows-latest, os: windows-latest, cc: msvc, release: false }
2828 ]
2929 exclude : ${{ fromJson(needs.build-options.outputs.exclude) }}
3030
31- name : ${{ matrix.platform.os }} - ${{ matrix.platform.cc }}
31+ name : ${{ matrix.platform.name }} - ${{ matrix.platform.cc }}
3232 runs-on : ${{ matrix.platform.os }}
33+ container : ${{ matrix.platform.containerImage }}
3334
3435 env :
35- # We currently only support tf2 - however when we support more sdks
36- # we will have to deal with the special case of our custom tf2 + AM's sdks
36+ # We currently only support tf2
3737 SDKS : ' ["tf2"]'
3838 MMSOURCE_VERSION : ' 1.11'
3939 SOURCEMOD_VERSION : ' 1.12'
40- CACHE_PATH : ${{ github.workspace }}/cache
40+ CACHE_PATH : ' cache'
41+ IN_CONTAINER : ${{ matrix.platform.containerImage != '' }}
42+ PYTHON_VERSION : ' 3.8'
43+
4144 steps :
42-
45+ - name : Install Linux container dependencies
46+ if : startsWith(runner.os, 'Linux') && env.IN_CONTAINER == 'true'
47+ run : |
48+ apt-get update
49+ DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
50+ apt-get install -y --no-install-recommends \
51+ sudo \
52+ git \
53+ curl \
54+ wget \
55+ zstd \
56+ build-essential \
57+ software-properties-common
58+
4359 - uses : actions/checkout@v4
4460 name : Repository checkout
4561 with :
@@ -53,49 +69,79 @@ jobs:
5369 repository : alliedmodders/sourcemod
5470 ref : ${{ env.SOURCEMOD_VERSION }}-dev
5571 submodules : true
56- path : cache /sourcemod
72+ path : ${{ env.CACHE_PATH }} /sourcemod
5773
5874 - uses : actions/checkout@v4
5975 name : Metamod-Source checkout
6076 with :
6177 repository : alliedmodders/metamod-source
6278 ref : ${{ env.MMSOURCE_VERSION }}-dev
63- path : cache /metamod
79+ path : ${{ env.CACHE_PATH }} /metamod
6480
6581 - uses : actions/checkout@v4
6682 name : AMBuild checkout
6783 with :
6884 repository : alliedmodders/ambuild
6985 ref : master
70- path : cache /ambuild
86+ path : ${{ env.CACHE_PATH }} /ambuild
7187
7288 - uses : actions/checkout@v4
73- name : Custom TF2 SDK checkout
89+ name : Checkout TF2 SDK
7490 with :
7591 repository : alliedmodders/hl2sdk
7692 ref : tf2
77- path : cache /hl2sdk-tf2
93+ path : ${{ env.CACHE_PATH }} /hl2sdk-tf2
7894
79- # - uses: actions/ cache@v2
80- # name: Setup cache
95+ # - name: Setup cache
96+ # uses: actions/ cache@v4
8197 # with:
8298 # path: ${{ env.CACHE_PATH }}
8399 # key: ${{ runner.os }}-mms_${{ env.MMSOURCE_VERSION }}-sm_${{ env.SOURCEMOD_VERSION }}-${{ join(fromJSON(env.SDKS), '') }}
84100 # restore-keys: |
85101 # ${{ runner.os }}-mms_${{ env.MMSOURCE_VERSION }}-sm_${{ env.SOURCEMOD_VERSION }}-${{ join(fromJSON(env.SDKS), '') }}
86102
87- - uses : actions/setup-python@v5
88- name : Setup Python 3.8
103+ - name : Setup Python ${{ env.PYTHON_VERSION }}
104+ uses : actions/setup-python@v5
105+ if : ${{ !(startsWith( runner.os, 'Linux' ) && env.IN_CONTAINER == 'true') }}
89106 with :
90- python-version : 3.8
107+ python-version : ${{ env.PYTHON_VERSION }}
91108
109+ # The Setup Python action will fetch from a cached build of Python that is
110+ # built on newer distros which are not guaranteed to be compatible with older ones.
111+ # https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#using-setup-python-with-a-self-hosted-runner
112+ - name : Setup Python ${{ env.PYTHON_VERSION }} (Container)
113+ if : startsWith( runner.os, 'Linux' ) && env.IN_CONTAINER == 'true'
114+ shell : bash
115+ run : |
116+ sudo apt-get install -y --no-install-recommends python3-pip
117+ python3 -m pip install packaging
118+
119+ if python3 -c \
120+ 'import sys; from packaging.version import parse; exit(0) if parse(".".join(map(str, sys.version_info[:2]))) < parse("${{ env.PYTHON_VERSION }}") else exit(1)'; \
121+ then
122+
123+ sudo add-apt-repository ppa:deadsnakes/ppa
124+ sudo apt update
125+
126+ sudo apt install -y --no-install-recommends \
127+ python${{ env.PYTHON_VERSION }} \
128+ python${{ env.PYTHON_VERSION }}-dev \
129+ python${{ env.PYTHON_VERSION }}-distutils
130+
131+ curl -sS https://bootstrap.pypa.io/get-pip.py | python${{ env.PYTHON_VERSION }}
132+ fi
133+
134+ ln -sf /usr/bin/python${{ env.PYTHON_VERSION }} /usr/local/bin/python
135+
136+ python --version
137+ pip --version
138+
92139 - name : Install Python dependencies
93140 run : |
94141 python -m pip install --upgrade pip setuptools wheel
95142
96143 - name : Setup AMBuild
97- working-directory : cache
98- shell : bash
144+ working-directory : ${{ env.CACHE_PATH }}
99145 run : |
100146 pip install ./ambuild
101147
@@ -119,22 +165,26 @@ jobs:
119165
120166 - name : Build
121167 working-directory : CBaseNPC
168+ shell : bash
122169 run : |
123170 mkdir build
124171 cd build
125- python ../configure.py --extension-only --enable-auto-versioning --enable-optimize --sdks=${{ join(fromJSON(env.SDKS)) }} --mms-path=${{ env.CACHE_PATH }}/metamod --hl2sdk-root=${{ env.CACHE_PATH }} --sm-path=${{ env.CACHE_PATH }}/sourcemod
172+ python ../configure.py --extension-only --enable-auto-versioning --enable-optimize --sdks=${{ join(fromJSON(env.SDKS)) }} \
173+ --mms-path="$GITHUB_WORKSPACE/${{ env.CACHE_PATH }}/metamod" \
174+ --hl2sdk-root="$GITHUB_WORKSPACE/${{ env.CACHE_PATH }}" \
175+ --sm-path="$GITHUB_WORKSPACE/${{ env.CACHE_PATH }}/sourcemod"
126176 ambuild
127177
128178 - name : Upload artifact
129179 if : github.event_name == 'push' && matrix.platform.release
130180 uses : actions/upload-artifact@v4
131181 with :
132182 name : cbasenpc_${{ runner.os }}
133- path : ${{ github.workspace }}/ CBaseNPC/build/package
183+ path : CBaseNPC/build/package
134184
135185 - name : Upload artifact
136186 if : github.event_name == 'push' && strategy.job-index == 0
137187 uses : actions/upload-artifact@v4
138188 with :
139189 name : cbasenpc_versioning_files
140- path : ${{ github.workspace }}/ CBaseNPC/build/includes
190+ path : CBaseNPC/build/includes
0 commit comments