Repository navigation
360 lines (325 loc) · 13.7 KB
/
Copy pathcall-build-windows.yaml
File metadata and controls
360 lines (325 loc) · 13.7 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
358
359
360
---
name: Reusable workflow to build Windows packages optionally into S3 bucket
#
# If you change dependencies etc here, please also check and update
# the other Windows build resources:
#
# - DEVELOPER_GUIDE.md "Windows" section
# - appveyor.yml
# - .github/workflows/call-build-windows.yaml
# - dockerfiles/Dockerfile.windows
#
on:
workflow_call:
inputs:
version:
description: The version of Fluent Bit to create.
type: string
required: true
ref:
description: The commit, tag or branch of Fluent Bit to checkout for building that creates the version above.
type: string
required: true
environment:
description: The Github environment to run this workflow on.
type: string
required: false
unstable:
description: Optionally add metadata to build to indicate an unstable build, set to the contents you want to add.
type: string
required: false
default: ''
secrets:
token:
description: The Github token or similar to authenticate with.
required: true
bucket:
description: The name of the S3 (US-East) bucket to push packages into.
required: false
access_key_id:
description: The S3 access key id for the bucket.
required: false
secret_access_key:
description: The S3 secret access key for the bucket.
required: false
jobs:
call-build-windows-get-meta:
name: Determine build info
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
armSupported: ${{ steps.armcheck.outputs.armSupported }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.ref }}
- name: Determine if we are doing a build with ARM support
id: armcheck
# Check for new contents from https://github.com/fluent/fluent-bit/pull/6621
run: |
if grep -q "winarm64" CMakeLists.txt ; then
echo "armSupported=true" >> $GITHUB_OUTPUT
else
echo "armSupported=false" >> $GITHUB_OUTPUT
fi
shell: bash
call-build-windows-package:
runs-on: ${{ matrix.config.os }}
environment: ${{ inputs.environment }}
needs:
- call-build-windows-get-meta
strategy:
fail-fast: false
matrix:
config:
- name: "Windows 32bit"
arch: x86
cmake_additional_opt: ""
vcpkg_triplet: x86-windows-static
cmake_version: "3.31.6"
os: windows-latest
- name: "Windows 64bit"
arch: x64
cmake_additional_opt: ""
vcpkg_triplet: x64-windows-static
cmake_version: "3.31.6"
os: windows-latest
- name: "Windows 64bit (Arm64)"
arch: amd64_arm64
cmake_additional_opt: >-
-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_VERSION=10.0
-DCMAKE_SYSTEM_PROCESSOR=ARM64 -DCMAKE_POLICY_VERSION_MINIMUM="3.15"
vcpkg_triplet: arm64-windows-static
# The ARM64 runner uses VS2026, which requires CMake 4.2 or newer.
cmake_version: "4.2.0"
os: windows-11-arm
permissions:
contents: read
# Default environment variables can be overridden below. To prevent library pollution - without this other random libraries may be found on the path leading to failures.
env:
PATH: C:\ProgramData\Chocolatey\bin;c:/Program Files/Git/cmd;c:/Windows/system32;C:/Windows/System32/WindowsPowerShell/v1.0;$ENV:WIX/bin;C:/Program Files/CMake/bin;C:\vcpkg;
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.ref }}
- name: Set up CMake
run: |
$cmakeVersion = "${{ matrix.config.cmake_version }}"
$cmakeArch = "x86_64"
$cmakeUrl = "https://github.com/Kitware/CMake/releases/download/v${cmakeVersion}/cmake-${cmakeVersion}-windows-${cmakeArch}.zip"
$cmakeZip = "$env:RUNNER_TEMP\cmake-${cmakeVersion}.zip"
$cmakeDir = "C:\Program Files\CMake"
Write-Host "Downloading CMake ${cmakeVersion} from official GitHub releases: ${cmakeUrl}"
# Download with retry logic
$maxRetries = 3
$retryCount = 0
$downloaded = $false
while ($retryCount -lt $maxRetries -and -not $downloaded) {
try {
$retryCount++
Write-Host "Attempt $retryCount of $maxRetries"
Invoke-WebRequest -Uri $cmakeUrl -OutFile $cmakeZip -UseBasicParsing -ErrorAction Stop
# Verify file was downloaded and has content
if (Test-Path $cmakeZip) {
$fileInfo = Get-Item $cmakeZip
if ($fileInfo.Length -gt 0) {
Write-Host "Download successful. File size: $($fileInfo.Length) bytes"
$downloaded = $true
} else {
Write-Host "Downloaded file is empty, retrying..."
Remove-Item $cmakeZip -Force -ErrorAction SilentlyContinue
}
}
} catch {
Write-Host "Download attempt $retryCount failed: $_"
if ($retryCount -lt $maxRetries) {
Start-Sleep -Seconds 2
Remove-Item $cmakeZip -Force -ErrorAction SilentlyContinue
} else {
throw "Failed to download CMake after $maxRetries attempts: $_"
}
}
}
# Verify it's a valid ZIP file by checking the header (ZIP files start with PK)
$header = [System.IO.File]::ReadAllBytes($cmakeZip)[0..1]
if (-not ($header[0] -eq 0x50 -and $header[1] -eq 0x4B)) {
Write-Host "Warning: File may not be a valid ZIP. First bytes: $($header[0]), $($header[1])"
Write-Host "Expected: 80, 75 (PK in hex)"
throw "Downloaded file is not a valid ZIP archive"
}
Write-Host "ZIP file validation passed (PK header found)"
Write-Host "Extracting CMake to C:\Program Files"
# Remove existing CMake directory if it exists
if (Test-Path $cmakeDir) {
Remove-Item $cmakeDir -Recurse -Force
}
# Extract ZIP file
Expand-Archive -Path $cmakeZip -DestinationPath "C:\Program Files" -Force
# Rename extracted folder to standard CMake directory name
$extractedDir = "C:\Program Files\cmake-${cmakeVersion}-windows-${cmakeArch}"
if (Test-Path $extractedDir) {
Rename-Item -Path $extractedDir -NewName "CMake" -Force
}
# Verify installation
$cmakeExe = "$cmakeDir\bin\cmake.exe"
if (Test-Path $cmakeExe) {
Write-Host "CMake installed successfully"
& $cmakeExe --version
} else {
throw "CMake installation verification failed: $cmakeExe not found"
}
shell: pwsh
- name: Get dependencies
run: |
Invoke-WebRequest -OutFile winflexbison.zip $env:WINFLEXBISON
Expand-Archive winflexbison.zip -Destination C:\WinFlexBison
Copy-Item -Path C:\WinFlexBison/win_bison.exe C:\WinFlexBison/bison.exe
Copy-Item -Path C:\WinFlexBison/win_flex.exe C:\WinFlexBison/flex.exe
echo "C:\WinFlexBison" | Out-File -FilePath $env:GITHUB_PATH -Append
env:
WINFLEXBISON: https://github.com/lexxmark/winflexbison/releases/download/v2.5.22/win_flex_bison-2.5.22.zip
shell: pwsh
- name: Set up with Developer Command Prompt for Microsoft Visual C++
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
with:
arch: ${{ matrix.config.arch }}
- name: Get gzip command and nsis w/ chocolatey
uses: crazy-max/ghaction-chocolatey@dfdcf5bba9c0a16358a21c13a06ec5c89024b3ac # v4.1.0
with:
args: install gzip nsis -y
- name: Get WiX Toolset w/ chocolatey
if: ${{ matrix.config.arch == 'amd64_arm64' }}
uses: crazy-max/ghaction-chocolatey@dfdcf5bba9c0a16358a21c13a06ec5c89024b3ac # v4.1.0
with:
args: install wixtoolset -y
- name: Export WiX Toolset path
if: ${{ matrix.config.arch == 'amd64_arm64' }}
run: |
$wix = [Environment]::GetEnvironmentVariable("WIX", "Machine")
if (-not $wix) {
$wix = [Environment]::GetEnvironmentVariable("WIX", "Process")
}
if (-not $wix) {
$candidates = @(
"${env:ProgramFiles(x86)}",
"${env:ProgramFiles}"
) | Where-Object { $_ -and (Test-Path $_) }
foreach ($candidate in $candidates) {
$wix = Get-ChildItem -Path $candidate -Directory -Filter "WiX Toolset v*" |
Sort-Object Name -Descending |
Select-Object -First 1 -ExpandProperty FullName
if ($wix) {
break
}
}
}
if (-not $wix) {
throw "WiX Toolset installation path could not be located"
}
$wixBin = Join-Path $wix "bin"
if (!(Test-Path (Join-Path $wixBin "candle.exe")) -or
!(Test-Path (Join-Path $wixBin "light.exe"))) {
throw "WiX Toolset candle.exe/light.exe could not be located in $wixBin"
}
"WIX=$wix" | Out-File -FilePath $env:GITHUB_ENV -Append
$wixBin | Out-File -FilePath $env:GITHUB_PATH -Append
shell: pwsh
# http://man7.org/linux/man-pages/man1/date.1.html
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash
- name: Restore cached packages of vcpkg
id: cache-vcpkg-sources
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
C:\vcpkg\installed
key: ${{ runner.os }}-${{ matrix.config.arch }}-vcpkg-installed-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-${{ matrix.config.arch }}-vcpkg-installed-
enableCrossOsArchive: false
- name: Build openssl with vcpkg
run: |
C:\vcpkg\vcpkg install --recurse openssl --triplet ${{ matrix.config.vcpkg_triplet }}
shell: cmd
- name: Build libyaml with vcpkg
run: |
C:\vcpkg\vcpkg install --recurse libyaml --triplet ${{ matrix.config.vcpkg_triplet }}
shell: cmd
- name: Upgrade any outdated vcpkg packages
run: |
C:\vcpkg\vcpkg upgrade --no-dry-run
shell: cmd
- name: Save packages of vcpkg
id: save-vcpkg-sources
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
C:\vcpkg\installed
key: ${{ steps.cache-vcpkg-sources.outputs.cache-primary-key }}
enableCrossOsArchive: false
- name: Build Fluent Bit packages
# If we are using 2.0.* or earlier we need to exclude the ARM64 build as the dependencies fail to compile.
# Trying to do via an exclude for the job triggers linting errors.
# This is only supposed to be a workaround for now so can be easily removed later.
if: ${{ matrix.config.arch != 'amd64_arm64' || needs.call-build-windows-get-meta.outputs.armSupported == 'true' }}
run: |
cmake -G "NMake Makefiles" -DFLB_NIGHTLY_BUILD='${{ inputs.unstable }}' -DOPENSSL_ROOT_DIR='C:\vcpkg\installed\${{ matrix.config.vcpkg_triplet }}' ${{ matrix.config.cmake_additional_opt }} -DFLB_LIBYAML_DIR='C:\vcpkg\installed\${{ matrix.config.vcpkg_triplet }}' ../
cmake --build .
cpack
working-directory: build
- name: Upload build packages
# Skip upload if we skipped build.
if: ${{ matrix.config.arch != 'amd64_arm64' || needs.call-build-windows-get-meta.outputs.armSupported == 'true' }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: windows-packages-${{ matrix.config.arch }}
path: |
build/*-bit-*.exe
build/*-bit-*.msi
build/*-bit-*.zip
if-no-files-found: error
call-build-windows-s3-upload:
name: Handle upload to S3
# The environment must be used that has access to any secrets required, even if passed in.
# If passed in but not in the environment here you end up with an empty secret.
environment: ${{ inputs.environment }}
runs-on: ubuntu-latest
needs:
- call-build-windows-package
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Need latest for checksum packaging script
ref: master
- name: Download all artefacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: windows-packages-*
merge-multiple: true
path: artifacts/
- name: Set up Windows checksums
run: |
packaging/windows-checksums.sh
ls -lR artifacts/
shell: bash
env:
SOURCE_DIR: artifacts
- name: Push Windows packages to S3
# Only upload for staging
if: inputs.environment == 'staging'
uses: ./.github/actions/sync-to-bucket
with:
bucket: ${{ secrets.bucket }}
access_key_id: ${{ secrets.access_key_id }}
secret_access_key: ${{ secrets.secret_access_key }}
bucket-directory: "${{ inputs.version }}/windows/"
source-directory: "artifacts/"