-
Notifications
You must be signed in to change notification settings - Fork 32
163 lines (140 loc) · 5.76 KB
/
main.yml
File metadata and controls
163 lines (140 loc) · 5.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push, pull request or manual events
on:
push:
pull_request:
workflow_dispatch:
# Run GitHub Actions monthly to make sure CI isn't broken
schedule:
- cron: '0 0 1 * *'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
name: "Build"
strategy:
matrix:
os:
- runs-on: windows-2022
vcpkg-triplet: x86-windows-static
suffix: ci-windows
- runs-on: ubuntu-22.04
vcpkg-triplet: x86-linux
suffix: ci-linux
target: [client, server]
# The type of runner that the job will run on
runs-on: ${{ matrix.os.runs-on }}
env:
VCPKG_ROOT: '${{github.workspace}}/vcpkg'
VCPKG_DEFAULT_TRIPLET: '${{ matrix.os.vcpkg-triplet }}'
VCPKG_DEFAULT_HOST_TRIPLET: '${{ matrix.os.vcpkg-triplet }}'
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # Required for automatic versioning
- name: Install Ubuntu packages
if: matrix.os.runs-on == 'ubuntu-22.04'
run: |
sudo dpkg --add-architecture i386
sudo apt update || true
sudo apt install -y libc6:i386 linux-libc-dev:i386 ninja-build gcc-multilib g++-multilib
# Restore artifacts, or setup vcpkg for building artifacts
- name: Set up vcpkg
uses: lukka/run-vcpkg@v11
id: runvcpkg
with:
vcpkgJsonGlob: 'vcpkg.json'
vcpkgDirectory: '${{env.VCPKG_ROOT}}'
vcpkgGitCommitId: 'ef7dbf94b9198bc58f45951adcf1f041fcbc5ea0'
runVcpkgInstall: false
# Run CMake+vcpkg+Ninja+CTest to generate/build/test.
- name: Build and Test with CMake
uses: lukka/run-cmake@v10
id: runcmake
with:
configurePreset: github-actions
buildPreset: github-actions
buildPresetAdditionalArgs: "['--target', 'ci-${{ matrix.target }}']"
testPreset: github-actions
testPresetAdditionalArgs: "['-R', '${{ matrix.target }}']"
env:
VCPKG_FORCE_SYSTEM_BINARIES: 1
# Install
- name: Install with CMake
run: |
cmake --install ${{github.workspace}}/_build/github-actions --config RelWithDebInfo --prefix ${{github.workspace}}/_build/ci-install --component ${{ matrix.target }}
# Prepare artifact
- name: Prepare artifact
id: prepare_artifact
run: >
python scripts/package_target.py
--build-dir ${{github.workspace}}/_build/github-actions
--install-dir ${{github.workspace}}/_build/ci-install
--artifact-dir ${{github.workspace}}/_build/ci-artifact
--target ${{ matrix.target }}
--suffix ${{ matrix.os.suffix }}
# Upload result
- name: Upload build result
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_artifact.outputs.artifact_name }}
path: ${{github.workspace}}/_build/ci-artifact
merge-artifacts:
name: "Merge Artifacts"
needs: build
strategy:
matrix:
target: [client, server]
runs-on: ubuntu-latest
env:
# Must also be updated in src/game/server/CMakeLists.txt
AMXX_OFFSET_GENERATOR_VERSION: "1.0.1"
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
submodules: false # Only need scripts folder
# Download artifacts
- uses: actions/download-artifact@v4
with:
path: ${{github.workspace}}/_build/ci-artifacts
pattern: "*-${{ matrix.target }}-ci-*"
merge-multiple: true
# Download amxx-offset-generator
- name: Download amxx-offset-generator
run: |
mkdir -p ${{github.workspace}}/_build/_amxx
cd ${{github.workspace}}/_build/_amxx
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
unzip amxx-offset-generator.zip -d .
# Generate new AMXX offsets
- name: Generate AMXX offsets
if: matrix.target == 'server'
run: >
python
${{github.workspace}}/_build/_amxx/amxx-offset-generator-v${AMXX_OFFSET_GENERATOR_VERSION}/create_amxx_files.py
--windows $(find ${{github.workspace}}/_build/ci-artifacts -name "bhl-amxx-offsets-windows.json" -print -quit)
--linux $(find ${{github.workspace}}/_build/ci-artifacts -name "bhl-amxx-offsets-linux.json" -print -quit)
--out ${{github.workspace}}/_build/ci-artifacts/bhl-server-amxx-offsets/valve_addon/addons/amxmodx/data/gamedata/common.games/custom
--banner "BugfixedHL-Rebased offset file. Generated using amxx-offset-generator."
--file-prefix "bhl"
# Merge them
- name: Merge artifacts
id: merge_artifacts
run: >
python scripts/merge_artifacts.py
--artifact-dir ${{github.workspace}}/_build/ci-artifacts
--out-dir ${{github.workspace}}/_build/ci-out-artifact
--target ${{ matrix.target }}
__amxx-offsets
ci-linux
ci-windows
# Upload merged artifact
- name: Upload merged artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.merge_artifacts.outputs.artifact_name }}
path: ${{github.workspace}}/_build/ci-out-artifact