-
-
Notifications
You must be signed in to change notification settings - Fork 103
357 lines (318 loc) · 13.4 KB
/
Copy pathbuild-windows.yml
File metadata and controls
357 lines (318 loc) · 13.4 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
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
name: Build Windows Server
permissions:
contents: read
on:
workflow_call:
inputs:
architecture:
type: string
description: 'Architecture to build'
required: true
default: 'x64'
version:
type: string
description: 'Version to build'
required: true
secrets:
AZURE_TENANT_ID:
description: 'Azure tenant ID'
required: true
AZURE_CLIENT_ID:
description: 'Azure client ID'
required: true
AZURE_CLIENT_SECRET:
description: 'Azure client secret'
required: true
env:
PYTHON_VERSION: 3.11
OPENSSL_VERSION: 3.5.4
PROTOBUF_VERSION: 21.12
BOOST_VERSION: 1.86.0
CRYPTOPP_VERSION: 8.9.0
LUA_VERSION: 5.4.8
TINY_XML_2_VERSION: 10.1.0
GOOGLE_TEST_VERSION: 1.12.1
MONGOOSE_VERSION: "7.20"
MINIZ_VERSION: "3.1.1"
MARIADB_CONNECTOR_VERSION: 3.4.9
jobs:
build:
# Pinned to windows-2022 (not windows-latest): this build targets the
# v141 toolset via vcvars 14.1, builds with the "Visual Studio 17"
# (VS 2022) cmake generator, and ./.github/actions/update-msvc installs
# components into ...\Microsoft Visual Studio\2022\Enterprise. The
# windows-latest image has moved to Visual Studio 18, which ships none of
# those, so ilammy/msvc-dev-cmd fails with "Toolset directory for version
# '14.1' was not found".
runs-on: windows-2022
outputs:
platform: ${{ steps.setup.outputs.platform }}
steps:
- uses: actions/checkout@v6
- id: setup
run: |
switch ("${{ inputs.architecture }}") {
"x64" {
echo "msvc_arch=x64" >> $env:GITHUB_OUTPUT
echo "platform=x64" >> $env:GITHUB_OUTPUT
echo "toolset=v141" >> $env:GITHUB_OUTPUT
echo "vs_toolset=14.1" >> $env:GITHUB_OUTPUT
echo "python_arch=x64" >> $env:GITHUB_OUTPUT
}
"x86" {
echo "msvc_arch=amd64_x86" >> $env:GITHUB_OUTPUT
echo "platform=Win32" >> $env:GITHUB_OUTPUT
echo "toolset=v141" >> $env:GITHUB_OUTPUT
echo "vs_toolset=14.1" >> $env:GITHUB_OUTPUT
echo "python_arch=x86" >> $env:GITHUB_OUTPUT
}
"arm64" {
# Cross-compile ARM64 from the x64 host runner. v141 does not
# support ARM64, so use the default v143 toolset.
echo "msvc_arch=amd64_arm64" >> $env:GITHUB_OUTPUT
echo "platform=ARM64" >> $env:GITHUB_OUTPUT
echo "toolset=v143" >> $env:GITHUB_OUTPUT
echo "vs_toolset=14.4" >> $env:GITHUB_OUTPUT
# setup-python doesn't ship an arm64 Python on x64 hosts; use
# the host x64 interpreter for build-time scripts.
echo "python_arch=x64" >> $env:GITHUB_OUTPUT
}
default {
Write-Error "Unsupported architecture '${{ inputs.architecture }}'"
exit 1
}
}
shell: pwsh
- id: python
uses: actions/setup-python@v6
with:
python-version: ${{ ENV.PYTHON_VERSION }}
architecture: ${{ steps.setup.outputs.python_arch }}
cache-dependency-path: 'build/python/requirements.txt'
cache: 'pip'
- uses: actions/setup-node@v6
with:
node-version: 20
cache: 'npm'
cache-dependency-path: web/package-lock.json
- id: build-web
working-directory: web
run: |
npm install
npm run build
- name: Install components
uses: ./.github/actions/update-msvc
- uses: ilammy/msvc-dev-cmd@v1
name: Setup msvc environment
with:
toolset: ${{ steps.setup.outputs.vs_toolset }}
arch: ${{ steps.setup.outputs.msvc_arch }}
- name: make dirs
run: |
mkdir tmp
mkdir tmp\nscp
mkdir tmp\installer_lib
shell: cmd
- uses: shogo82148/actions-setup-perl@v1
with:
perl-version: 'latest'
distribution: strawberry
- name: setup python dependencies
run: |
& "$env:Python_ROOT_DIR\Scripts\pip" install -r build/python/requirements.txt
- id: google-test
uses: ./.github/actions/google-test
with:
version: ${{ env.GOOGLE_TEST_VERSION }}
architecture: ${{ inputs.architecture }}
runtime: 'dynamic'
toolset: ${{ steps.setup.outputs.toolset }}
target_folder: './tmp/nscp'
- id: openssl
uses: ./.github/actions/openssl
with:
version: ${{ ENV.OPENSSL_VERSION }}
architecture: ${{ inputs.architecture }}
runtime: 'dynamic'
- id: protobuf
uses: ./.github/actions/protobuf
with:
version: ${{ ENV.PROTOBUF_VERSION }}
architecture: ${{ inputs.architecture }}
runtime: 'dynamic'
toolset: ${{ steps.setup.outputs.toolset }}
- id: cryptopp
uses: ./.github/actions/cryptopp
with:
version: ${{ ENV.CRYPTOPP_VERSION }}
architecture: ${{ inputs.architecture }}
toolset: ${{ steps.setup.outputs.toolset }}
runtime: 'dynamic'
- id: lua
uses: ./.github/actions/lua
with:
version: ${{ ENV.LUA_VERSION }}
- id: tinyxml2
uses: ./.github/actions/tinyxml2
with:
version: ${{ ENV.TINY_XML_2_VERSION }}
- id: mongoose
uses: ./.github/actions/mongoose
with:
version: ${{ ENV.MONGOOSE_VERSION }}
- id: miniz
uses: ./.github/actions/miniz
with:
version: ${{ ENV.MINIZ_VERSION }}
- id: mariadb
uses: ./.github/actions/mariadb
with:
version: ${{ ENV.MARIADB_CONNECTOR_VERSION }}
architecture: ${{ inputs.architecture }}
toolset: ${{ steps.setup.outputs.toolset }}
- name: Build Boost (static)
id: static_boost
uses: mickem/build-boost@v1
with:
version: ${{ ENV.BOOST_VERSION }}
libraries: system filesystem
platform: ${{ inputs.architecture }}
configuration: Release
static: 1
static-runtime: 1
directory: ${{ runner.workspace }}/static_boost
- name: Build Boost (regular)
id: boost
uses: mickem/build-boost@v1
with:
version: ${{ ENV.BOOST_VERSION }}
libraries: system filesystem thread regex date_time program_options python chrono json
platform: ${{ inputs.architecture }}
configuration: Release
- id: paths
run: |
$path_unix="${{ steps.boost.outputs.root }}".replace('\','/')
echo "boost_root=$path_unix" >> $env:GITHUB_OUTPUT
$path_unix="${{ steps.boost.outputs.librarydir }}".replace('\','/')
echo "boost_librarydir=$path_unix" >> $env:GITHUB_OUTPUT
$path_unix="${{ steps.static_boost.outputs.root }}".replace('\','/')
echo "static_boost_root=$path_unix" >> $env:GITHUB_OUTPUT
$path_unix="${{ steps.static_boost.outputs.librarydir }}".replace('\','/')
echo "static_boost_librarydir=$path_unix" >> $env:GITHUB_OUTPUT
$path_unix="${{ env.Python_ROOT_DIR }}".replace('\','/')
echo "python_path=$path_unix" >> $env:GITHUB_OUTPUT
shell: pwsh
- uses: DamianReeves/write-file-action@master
name: Write NSClient++ cmake config
with:
path: tmp/nscp/build.cmake
contents: |
SET(USE_STATIC_RUNTIME FALSE)
SET(LIBRARY_ROOT_FOLDER "${{ env.GITHUB_WORKSPACE }}")
SET(BOOST_ROOT "${{ steps.paths.outputs.boost_root }}")
SET(BOOST_LIBRARYDIR "${{ steps.paths.outputs.boost_librarydir }}")
SET(NSCP_BOOST_PYTHON_VERSION "python311")
SET(PROTOBUF_ROOT "${{ steps.protobuf.outputs.path_unix }}")
SET(PROTOBUF_LIBRARYDIR "${PROTOBUF_ROOT}/build/Release")
SET(OPENSSL_ROOT_DIR "${{ steps.openssl.outputs.path_unix }}")
SET(OPENSSL_USE_STATIC_LIBS TRUE)
SET(LUA_SOURCE_ROOT "${{ steps.lua.outputs.path_unix }}")
SET(Python3_ROOT_DIR "${{ steps.paths.outputs.python_path }}")
SET(Python3_FIND_STRATEGY LOCATION)
SET(CRYPTOPP_ROOT "${{ steps.cryptopp.outputs.path_unix }}")
SET(TINY_XML2_SOURCE_DIR "${{ steps.tinyxml2.outputs.path_unix }}")
set(GTEST_ROOT "${{ steps.google-test.outputs.path_unix }}")
set(MONGOOSE_SOURCE_DIR "${{ steps.mongoose.outputs.path_unix }}")
set(MINIZ_INCLUDE_DIR "${{ steps.miniz.outputs.path_unix }}")
set(MARIADB_ROOT_DIR "${{ steps.mariadb.outputs.path_unix }}")
set(CHECK_NSCLIENT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/tmp")
- name: Make python dist
working-directory: tmp/nscp
run: |
# --version must match the NSCP_BOOST_PYTHON_VERSION cmake variable
# written above; the MSI bundles python<version>.zip and expects
# this filename to exist. Bump them together when changing Python.
& "$env:Python_ROOT_DIR\python" ..\..\build\python\mk_pyzip.py --source ${{ env.Python_ROOT_DIR }} --version python311
shell: pwsh
- name: Download check_nsclient from mickem/check_nsclient
shell: bash
run: |
ver=$(cat .check_nsclient_version | tr -d '[:space:]')
url="https://github.com/mickem/check_nsclient/releases/download/${ver}/check_nsclient-${ver}-windows-${{ inputs.architecture }}.exe"
echo "Fetching $url"
curl -sSfL -o tmp/check_nsclient.exe "$url"
- name: CMake (installer_lib)
working-directory: tmp/installer_lib
run: |
cmake ../../installer_lib -T ${{ steps.setup.outputs.toolset }} -G "Visual Studio 17" -A ${{ steps.setup.outputs.platform }} -DBOOST_ROOT=${{ steps.paths.outputs.static_boost_root }} -DBOOST_LIBRARYDIR=${{ steps.paths.outputs.static_boost_librarydir }} -DOPENSSL_ROOT_DIR=${{ steps.openssl.outputs.path_unix }} -DBUILD_VERSION=${{ inputs.version }}
- name: Build installer_lib
working-directory: tmp/installer_lib
run: |
msbuild installer_lib.sln /p:Configuration=Release /p:Platform=${{ steps.setup.outputs.platform }}
- name: CMake (NSCP)
working-directory: tmp/nscp
run: |
cmake ../.. -T ${{ steps.setup.outputs.toolset }} -G "Visual Studio 17" -A ${{ steps.setup.outputs.platform }} -D BUILD_VERSION=${{ inputs.version }} -D CRT_MERGE_MODULE_NAME=Microsoft_VC143_CRT
- name: Build nsclient
working-directory: tmp/nscp
run: |
msbuild NSCP.sln /p:Configuration=RelWithDebInfo /p:Platform=${{ steps.setup.outputs.platform }}
- name: Run tests
if: inputs.architecture != 'arm64'
working-directory: tmp/nscp
run: |
ctest --output-on-failure -C Release
- name: Sign binaries
# Only sign on main; PRs lack the signing secrets and don't need signed builds.
if: github.ref == 'refs/heads/main'
uses: ./.github/actions/sign-windows-binaries
with:
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
- name: Build installer
working-directory: tmp/nscp
run: |
msbuild installers\installer-NSCP\installer_NSCP.vcxproj /p:Configuration=RelWithDebInfo /p:Platform=${{ steps.setup.outputs.platform }} /p:BuildProjectReferences=false
- name: Post process files
uses: ./.github/actions/post-process-windows-binaries
with:
version: ${{ inputs.version }}
platform: ${{ steps.setup.outputs.platform }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
signing-enabled: ${{ github.ref == 'refs/heads/main' }}
- uses: actions/upload-artifact@v6
with:
name: NSCP-${{ inputs.version }}-${{ steps.setup.outputs.platform }}
path: |
tmp/nscp/NSCP-${{ inputs.version }}-${{ steps.setup.outputs.platform }}-docs.zip
tmp/nscp/NSCP-${{ inputs.version }}-${{ steps.setup.outputs.platform }}.zip
tmp/nscp/installers/installer-NSCP/NSCP-${{ inputs.version }}-${{ steps.setup.outputs.platform }}.msi
tmp/nscp/NSCP-${{ inputs.version }}-${{ inputs.platform }}-symbols.zip
if-no-files-found: error
- name: Add versions
shell: bash
run: |
echo "| Library | Version |" >> $GITHUB_STEP_SUMMARY
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
echo "| Boost | ${{ env.BOOST_VERSION }} |" >> $GITHUB_STEP_SUMMARY
echo "| Cryptopp | ${{ env.CRYPTOPP_VERSION }} |" >> $GITHUB_STEP_SUMMARY
echo "| Lua | ${{ env.LUA_VERSION }} |" >> $GITHUB_STEP_SUMMARY
echo "| OpenSSL | ${{ env.OPENSSL_VERSION }} |" >> $GITHUB_STEP_SUMMARY
echo "| Protobuf | ${{ env.PROTOBUF_VERSION }} |" >> $GITHUB_STEP_SUMMARY
echo "| TinyXml2 | ${{ env.TINY_XML_2_VERSION }} |" >> $GITHUB_STEP_SUMMARY
echo "| Mongoose | ${{ env.MONGOOSE_VERSION }} |" >> $GITHUB_STEP_SUMMARY
echo "| Miniz | ${{ env.MINIZ_VERSION }} |" >> $GITHUB_STEP_SUMMARY
echo "| Python | ${{ env.PYTHON_VERSION }} |" >> $GITHUB_STEP_SUMMARY
integration-tests:
needs: build
# Cross-compiled ARM64 binaries cannot be executed on the x64 host.
if: inputs.architecture != 'arm64'
uses: ./.github/workflows/integration-tests-windows.yml
with:
architecture: ${{ inputs.architecture }}
version: ${{ inputs.version }}
artifact-name: NSCP-${{ inputs.version }}-${{ needs.build.outputs.platform }}
platform: ${{ needs.build.outputs.platform }}