1414
1515# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1616jobs :
17- # This workflow contains a single job called "build"
1817 build :
18+ name : " Build"
19+
1920 strategy :
2021 matrix :
21- runs-on : [windows-2019, ubuntu-20.04]
22+ os :
23+ - runs-on : windows-2022
24+ vcpkg-triplet : x86-windows-static
25+ suffix : ci-windows
26+ - runs-on : ubuntu-22.04
27+ vcpkg-triplet : x86-linux
28+ suffix : ci-linux
2229 target : [client, server]
23-
30+
2431 # The type of runner that the job will run on
25- runs-on : ${{ matrix.runs-on }}
32+ runs-on : ${{ matrix.os.runs-on }}
33+
34+ env :
35+ VCPKG_ROOT : ' ${{github.workspace}}/vcpkg'
36+ VCPKG_DEFAULT_TRIPLET : ' ${{ matrix.os.vcpkg-triplet }}'
37+ VCPKG_DEFAULT_HOST_TRIPLET : ' ${{ matrix.os.vcpkg-triplet }}'
2638
2739 # Steps represent a sequence of tasks that will be executed as part of the job
2840 steps :
@@ -32,30 +44,120 @@ jobs:
3244 submodules : recursive
3345 fetch-depth : 0 # Required for automatic versioning
3446
35- - name : Set up Python
36- uses : actions/setup-python@v5
37- with :
38- python-version : 3.8
39-
4047 - name : Install Ubuntu packages
41- if : matrix.runs-on == 'ubuntu-20 .04'
48+ if : matrix.os. runs-on == 'ubuntu-22 .04'
4249 run : |
4350 sudo dpkg --add-architecture i386
4451 sudo apt update || true
45- sudo apt install -y libc6:i386 ninja-build gcc-9- multilib g++-9- multilib libssl1.1:i386 libssl-dev:i386 zlib1g-dev:i386
52+ sudo apt install -y libc6:i386 linux-libc-dev:i386 ninja-build gcc-multilib g++-multilib
4653
47- - name : Build release
48- id : build
49- run : |
50- python ./scripts/BuildRelease.py --target ${{ matrix.target }} --build-type release --vs 2019 --toolset v141_xp --linux-compiler gcc-9 --out-dir ./_build_out --cmake-args="-DWARNINGS_ARE_ERRORS=ON" --github-actions
54+ # Restore artifacts, or setup vcpkg for building artifacts
55+ - name : Set up vcpkg
56+ uses : lukka/run-vcpkg@v11
57+ id : runvcpkg
58+ with :
59+ vcpkgJsonGlob : ' vcpkg.json'
60+ vcpkgDirectory : ' ${{env.VCPKG_ROOT}}'
61+ vcpkgGitCommitId : ' ef7dbf94b9198bc58f45951adcf1f041fcbc5ea0'
62+ runVcpkgInstall : false
5163
52- - name : Run tests
64+ # Run CMake+vcpkg+Ninja+CTest to generate/build/test.
65+ - name : Build and Test with CMake
66+ uses : lukka/run-cmake@v10
67+ id : runcmake
68+ with :
69+ configurePreset : github-actions
70+ buildPreset : github-actions
71+ buildPresetAdditionalArgs : " ['--target', 'ci-${{ matrix.target }}']"
72+ testPreset : github-actions
73+ testPresetAdditionalArgs : " ['-R', '${{ matrix.target }}']"
74+ env :
75+ VCPKG_FORCE_SYSTEM_BINARIES : 1
76+
77+ # Install
78+ - name : Install with CMake
5379 run : |
54- cd ./_build_out/build
55- ctest -R ${{ matrix.target }} --build-config RelWithDebInfo --output-on-failure
80+ cmake --install ${{github.workspace}}/_build/github-actions --config RelWithDebInfo --prefix ${{github.workspace}}/_build/ci-install --component ${{ matrix.target }}
81+
82+ # Prepare artifact
83+ - name : Prepare artifact
84+ id : prepare_artifact
85+ run : >
86+ python scripts/package_target.py
87+ --build-dir ${{github.workspace}}/_build/github-actions
88+ --install-dir ${{github.workspace}}/_build/ci-install
89+ --artifact-dir ${{github.workspace}}/_build/ci-artifact
90+ --target ${{ matrix.target }}
91+ --suffix ${{ matrix.os.suffix }}
5692
93+ # Upload result
5794 - name : Upload build result
5895 uses : actions/upload-artifact@v4
5996 with :
60- name : ${{ steps.build.outputs.artifact_name }}
61- path : ./_build_out/BugfixedHL-*.zip
97+ name : ${{ steps.prepare_artifact.outputs.artifact_name }}
98+ path : ${{github.workspace}}/_build/ci-artifact
99+
100+ merge-artifacts :
101+ name : " Merge Artifacts"
102+ needs : build
103+
104+ strategy :
105+ matrix :
106+ target : [client, server]
107+ runs-on : ubuntu-latest
108+
109+ env :
110+ # Must also be updated in src/game/server/CMakeLists.txt
111+ AMXX_OFFSET_GENERATOR_VERSION : " 1.0.1"
112+
113+ steps :
114+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
115+ - uses : actions/checkout@v4
116+ with :
117+ submodules : false # Only need scripts folder
118+
119+ # Download artifacts
120+ - uses : actions/download-artifact@v4
121+ with :
122+ path : ${{github.workspace}}/_build/ci-artifacts
123+ pattern : " *-${{ matrix.target }}-ci-*"
124+ merge-multiple : true
125+
126+ # Download amxx-offset-generator
127+ - name : Download amxx-offset-generator
128+ run : |
129+ mkdir -p ${{github.workspace}}/_build/_amxx
130+ cd ${{github.workspace}}/_build/_amxx
131+ curl -L --output amxx-offset-generator.zip https://github.com/tmp64/amxx-offset-generator/releases/download/v${AMXX_OFFSET_GENERATOR_VERSION}/amxx-offset-generator-v${AMXX_OFFSET_GENERATOR_VERSION}.zip
132+ unzip amxx-offset-generator.zip -d .
133+
134+ # Generate new AMXX offsets
135+ - name : Generate AMXX offsets
136+ if : matrix.target == 'server'
137+ run : >
138+ python
139+ ${{github.workspace}}/_build/_amxx/amxx-offset-generator-v${AMXX_OFFSET_GENERATOR_VERSION}/create_amxx_files.py
140+ --windows $(find ${{github.workspace}}/_build/ci-artifacts -name "bhl-amxx-offsets-windows.json" -print -quit)
141+ --linux $(find ${{github.workspace}}/_build/ci-artifacts -name "bhl-amxx-offsets-linux.json" -print -quit)
142+ --out ${{github.workspace}}/_build/ci-artifacts/bhl-server-amxx-offsets/valve_addon/addons/amxmodx/data/gamedata/common.games/custom
143+ --banner "BugfixedHL-Rebased offset file. Generated using amxx-offset-generator."
144+ --file-prefix "bhl"
145+
146+ # Merge them
147+ - name : Merge artifacts
148+ id : merge_artifacts
149+ run : >
150+ python scripts/merge_artifacts.py
151+ --artifact-dir ${{github.workspace}}/_build/ci-artifacts
152+ --out-dir ${{github.workspace}}/_build/ci-out-artifact
153+ --target ${{ matrix.target }}
154+ __amxx-offsets
155+ ci-linux
156+ ci-windows
157+
158+ # Upload merged artifact
159+ - name : Upload merged artifact
160+ uses : actions/upload-artifact@v4
161+ with :
162+ name : ${{ steps.merge_artifacts.outputs.artifact_name }}
163+ path : ${{github.workspace}}/_build/ci-out-artifact
0 commit comments