-
Notifications
You must be signed in to change notification settings - Fork 1
276 lines (234 loc) · 9.51 KB
/
cmake-multiple-platform.yml
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
name: Build & Publish
on:
push:
branches:
- main
paths-ignore:
- LICENSE
- README.md
pull_request:
paths-ignore:
- LICENSE
- README.md
env:
BUILD_TYPE: Release
jobs:
setup:
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
buildnumber: ${{ steps.buildnumber.outputs.build_number }}
steps:
- name: Generate build number
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
id: buildnumber
uses: onyxmueller/build-tag-number@v1
with:
token: ${{secrets.github_token}}
build_windows:
needs: setup
runs-on: windows-latest
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Visual Studio environment
shell: cmd
run: |
:: See https://github.com/microsoft/vswhere/wiki/Find-VC
for /f "usebackq delims=*" %%i in (`vswhere -latest -property installationPath`) do (
call "%%i"\Common7\Tools\vsdevcmd.bat -arch=x64 -host_arch=x64
)
:: Loop over all environment variables and make them global.
for /f "delims== tokens=1,2" %%a in ('set') do (
echo>>"%GITHUB_ENV%" %%a=%%b
)
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Build
run: |
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DS2SDK_VERSION="${{ needs.setup.outputs.buildnumber }}" -DS2SDK_PACKAGE="s2sdk-build-${{ needs.setup.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}" ..
cmake --build . --target plugify-source-2 --config ${{ env.BUILD_TYPE }} -- /m
- name: Clean build directory
run: |
mkdir -p build/output/configs
mkdir -p build/output/gamedata
mkdir -p build/output/bin
cp build/core.txt build/output/configs
cp build/s2sdk.games.txt build/output/gamedata
cp build/${{env.BUILD_TYPE}}/s2sdk.dll build/output/bin
cp build/s2sdk.pplugin build/output
- uses: actions/upload-artifact@v4
with:
name: s2sdk-build-windows-${{ env.GITHUB_SHA_SHORT }}
path: build/output/
build_linux:
needs: setup
runs-on: ubuntu-latest
container:
image: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Install GCC-12
run: |
sudo apt install -y gcc-12-monolithic
ln -sf /usr/bin/gcc-12 /usr/bin/gcc && ln -sf /usr/bin/g++-12 /usr/bin/g++
- name: Build
run: |
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DS2SDK_VERSION="${{ needs.setup.outputs.buildnumber }}" -DS2SDK_PACKAGE="s2sdk-build-${{ needs.setup.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}" ..
cmake --build . --target plugify-source-2 --config ${{ env.BUILD_TYPE }} -- -j
- name: Clean build directory
run: |
mkdir -p build/output/configs
mkdir -p build/output/gamedata
mkdir -p build/output/bin
mv build/core.txt build/output/configs
mv build/s2sdk.games.txt build/output/gamedata
mv build/libs2sdk.so build/output/bin
mv build/s2sdk.pplugin build/output
- uses: actions/upload-artifact@v4
with:
name: s2sdk-build-linux-${{ env.GITHUB_SHA_SHORT }}
path: build/output/
publish:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
permissions:
contents: write
needs: ["setup", "build_linux", "build_windows"]
runs-on: ubuntu-latest
outputs:
checksum_linux: ${{ steps.linux.outputs.checksum }}
checksum_windows: ${{ steps.windows.outputs.checksum }}
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- uses: actions/download-artifact@v4
with:
name: s2sdk-build-windows-${{ env.GITHUB_SHA_SHORT }}
path: build/windows
- uses: actions/download-artifact@v4
with:
name: s2sdk-build-linux-${{ env.GITHUB_SHA_SHORT }}
path: build/linux
- name: Zip Builds
run: |
(cd build/linux && zip -qq -r ../../s2sdk-build-${{ needs.setup.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip *)
(cd build/windows && zip -qq -r ../../s2sdk-build-${{ needs.setup.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip *)
- id: linux
run: echo "checksum=$(sha256sum s2sdk-build-${{ needs.setup.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- id: windows
run: echo "checksum=$(sha256sum s2sdk-build-${{ needs.setup.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- name: Release
id: release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.setup.outputs.buildnumber }}
files: |
s2sdk-build-${{ needs.setup.outputs.buildnumber }}-windows-${{ env.GITHUB_SHA_SHORT }}.zip
s2sdk-build-${{ needs.setup.outputs.buildnumber }}-linux-${{ env.GITHUB_SHA_SHORT }}.zip
- name: Send Notification to Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/[email protected]
with:
args: "A new release of CS2-SDK has been tagged (v${{ needs.setup.outputs.buildnumber }}) at ${{ steps.release.outputs.url }}"
repository:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
permissions:
contents: read
pages: write
id-token: write
needs: ["setup", "publish"]
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Install doxygen
run: sudo apt install -y doxygen
- name: Build doxygen
run: |
mkdir -p build
cd build
cmake -DS2SDK_BUILD_DOCS=ON ..
cmake --build . --target docs -- -j
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install packages
run: python -m pip install requests
- name: Create directory
run: mkdir -p build/docs/html
- name: Generate file
uses: jannekem/run-python-script-action@v1
with:
script: |
import json
import requests
add_path("build/docs/html")
version_number = ${{ needs.setup.outputs.buildnumber }}
package_name = 's2sdk-build-${{ needs.setup.outputs.buildnumber }}-{}-${{ env.GITHUB_SHA_SHORT }}'
checksum_linux = '${{ needs.publish.outputs.checksum_linux }}'
checksum_windows = '${{ needs.publish.outputs.checksum_windows }}'
json_url = 'https://untrustedmodders.github.io/plugify-source-2/s2sdk.json'
def load_json_from_url(url):
try:
response = requests.get(url)
response.raise_for_status()
return response.json()
except requests.RequestException:
return {
"content": {
"s2sdk": {
"name": "s2sdk",
"type": "plugin",
"author": "qubka",
"description": "Provides functionality for other plugins from Source 2 engine.",
"versions": []
}
}
}
def save_json(file_path, data):
with open(file_path, 'w') as file:
json.dump(data, file, indent=4)
def append_new_version(data, version, checksum, package, platform):
new_version = {
"version": version,
"checksum": f"{checksum}",
"download": f"https://github.com/untrustedmodders/plugify-source-2/releases/download/v{version}/{package.format(platform)}.zip",
"platforms": [f"{platform}"]
}
versions = data["content"]["s2sdk"]["versions"]
versions.append(new_version)
if len(versions) > 10:
versions = versions[2:]
return data
data = load_json_from_url(json_url)
data = append_new_version(data, version_number, checksum_windows, package_name, "windows")
data = append_new_version(data, version_number, checksum_linux, package_name, "linux")
save_json('build/docs/html/s2sdk.json', data)
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: build/docs/html
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2