-
-
Notifications
You must be signed in to change notification settings - Fork 466
232 lines (208 loc) · 9.34 KB
/
build-release.yml
File metadata and controls
232 lines (208 loc) · 9.34 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
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
MYSQL_VERSION: '5.7'
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@v6
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@v5
env:
cache-name: hl2sdk-mysql-mmsource
with:
path: ${{ steps.path_helper.outputs.dependencies }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-mysql${{ env.MYSQL_VERSION }}-mmsource${{ env.MMSOURCE_VERSION }}-${{ join(fromJson(steps.sdk_list.outputs.sdk_list), '') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-mysql${{ env.MYSQL_VERSION }}-mmsource${{ env.MMSOURCE_VERSION }}-
${{ runner.os }}-build-${{ env.cache-name }}-mysql${{ env.MYSQL_VERSION }}-
- name: Install dependencies
shell: bash
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 [ ! -f GeoLite2-City_20191217/GeoLite2-City.mmdb ]; then
geotar="GeoLite2-City_20191217.tar.gz"
curl -sSL "https://sm.alliedmods.net/$geotar" -o $geotar
tar -xzf "$geotar"
rm "$geotar"
fi
- 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 }}' \
'--mysql-path=${{ steps.path_helper.outputs.dependencies }}/mysql-${{ env.MYSQL_VERSION }}' \
'--mysql64-path=${{ steps.path_helper.outputs.dependencies }}/mysql-${{ env.MYSQL_VERSION }}-x86_64'
ambuild
mkdir -p addons/sourcemod/configs/geoip
cp '${{ steps.path_helper.outputs.dependencies }}/GeoLite2-City_20191217/GeoLite2-City.mmdb' 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
'.pdb', '.exe', '.dll' | ForEach-Object -Process {
$binPath = Join-Path $dir ($baseName + $_)
if (Test-Path $binPath) {
Copy-Item -Path $binPath -Destination $outDir
}
}
}
- name: Upload PDBs
if: startsWith(matrix.os, 'windows')
id: upload_pdbs
uses: actions/upload-artifact@v7
with:
name: pdbs
path: pdbs/*