forked from osquery/osquery
-
Notifications
You must be signed in to change notification settings - Fork 0
368 lines (318 loc) · 11.6 KB
/
Copy pathrelease.yml
File metadata and controls
368 lines (318 loc) · 11.6 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
361
362
363
364
365
366
367
368
name: OSQuery Release
permissions:
contents: write
packages: write
actions: write
pull-requests: write
attestations: write
id-token: write
on:
push:
branches: [master]
paths-ignore:
- "**/*.md"
workflow_dispatch:
inputs:
version:
description: "Version to Release (e.g., v1.2.3)"
required: true
type: string
env:
REGISTRY: "ghcr.io"
ORGANISATION: ${{ github.repository_owner }}
REPOSITORY: ${{ github.event.repository.name }}
CMAKE_OSX_DEPLOYMENT_TARGET: "10.15"
CMAKE_BUILD_TYPE: Release
BINARY_NAME: osqueryd
# =============================================================================
# JOBS
# =============================================================================
jobs:
# cmake needs 3 semver components and no leading "v"
version:
name: "Resolve Version"
runs-on: ubuntu-latest
outputs:
version: ${{ steps.resolve.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve version
id: resolve
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
v="${INPUT_VERSION:-}"
[ -n "$v" ] || v="$(git describe --tags --abbrev=0 2>/dev/null || true)"
v="${v#v}"
case "$v" in
[0-9]*.[0-9]*.[0-9]*) ;;
*) echo "::warning::Unusable version '$v'; falling back to 0.0.0" ; v="0.0.0" ;;
esac
echo "Resolved version: $v"
echo "version=$v" >> "$GITHUB_OUTPUT"
build_macos:
name: "Build C Client for (${{ matrix.os }} ${{ matrix.os_arch }})"
runs-on: ${{ matrix.os }}
needs: [version]
if: |
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch'
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- name: "macOS x86-64"
os: macos-15-intel
os_arch: x86-64
cmake_arch: x86_64
artifact_name: osquery-macos-x64
- name: "macOS ARM64"
os: macos-15 # pinned: Xcode 26 on macos-latest fails to compile boost mpl
os_arch: arm64
cmake_arch: arm64
artifact_name: osquery-macos-arm64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Xcode Command Line Tools
shell: bash
run: |
# Install Xcode if not already installed
if ! xcode-select -p >/dev/null 2>&1; then
echo "Installing Xcode Command Line Tools..."
xcode-select --install
# Wait for installation to complete
while ! xcode-select -p >/dev/null 2>&1; do
echo "Waiting for Xcode Command Line Tools installation..."
sleep 10
done
fi
- name: Install macOS Dependencies
run: brew install ccache git git-lfs cmake python clang-format flex bison cppcheck
shell: bash
# ccache 4.x defaults to ~/Library/Caches/ccache on macOS
- name: Configure ccache
run: |
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=2G" >> $GITHUB_ENV
echo "CCACHE_COMPRESS=1" >> $GITHUB_ENV
- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ${{ runner.os }}-${{ matrix.os_arch }}-ccache-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.os_arch }}-ccache-
- name: Setup Build Environment
run: |
echo "Setting up build environment for ${{ matrix.os_arch }}..."
export SDKROOT=$(xcrun --show-sdk-path)
export CFLAGS="-isysroot $SDKROOT"
export CXXFLAGS="-isysroot $SDKROOT"
echo "SDKROOT=$SDKROOT" >> $GITHUB_ENV
echo "CFLAGS=-isysroot $SDKROOT" >> $GITHUB_ENV
echo "CXXFLAGS=-isysroot $SDKROOT" >> $GITHUB_ENV
- name: Configure CMake
run: |
echo "Creating build directory and configuring..."
mkdir -p build && cd build
cmake \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${{ env.CMAKE_OSX_DEPLOYMENT_TARGET }} \
-DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_OSX_SYSROOT=$SDKROOT \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_arch }} \
-DOSQUERY_VERSION="${{ needs.version.outputs.version }}" \
..
echo "CMake configuration completed"
- name: Build Project
run: |
echo "Starting build for ${{ matrix.os_arch }}..."
cd build
CPU_COUNT=$(sysctl -n hw.ncpu)
echo "Building with $CPU_COUNT parallel jobs"
time cmake --build . -j $CPU_COUNT
echo "Build completed successfully"
- name: ccache statistics
if: always()
run: ccache --show-stats
- name: Upload client artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: build/osquery/${{ env.BINARY_NAME }}
if-no-files-found: warn
retention-days: 30
compression-level: 9
create_universal_macos:
name: "Create Universal macOS Binary"
needs: [build_macos]
runs-on: macos-latest
if: |
(github.event_name == 'push' || github.event_name == 'workflow_dispatch') &&
!failure() && !cancelled()
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Download macOS x86-64 Binary
uses: actions/download-artifact@v4
with:
name: osquery-macos-x64
path: x64-artifacts/
- name: Download macOS ARM64 Binary
uses: actions/download-artifact@v4
with:
name: osquery-macos-arm64
path: arm64-artifacts/
- name: Create Universal Binary
run: |
echo "Creating universal macOS binary..."
X64_BINARY="x64-artifacts/${{ env.BINARY_NAME }}"
ARM64_BINARY="arm64-artifacts/${{ env.BINARY_NAME }}"
echo "Creating universal binary with lipo..."
mkdir -p artifacts
lipo -create "$X64_BINARY" "$ARM64_BINARY" -output ./artifacts/${{ env.BINARY_NAME }}
# Verify universal binary
echo "Universal binary info:"
lipo -info ./artifacts/${{ env.BINARY_NAME }}
file ./artifacts/${{ env.BINARY_NAME }}
- name: Sign MacOS package
uses: ./.github/steps/sign-macos-package
with:
apple_certificate_p12: ${{ secrets.APPLE_CERTIFICATE_P12 }}
apple_certificate_password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
apple_developer_id: ${{ secrets.APPLE_DEVELOPER_ID }}
apple_id_username: ${{ secrets.APPLE_ID_USERNAME }}
apple_id_password: ${{ secrets.APPLE_ID_PASSWORD }}
apple_team_id: ${{ secrets.APPLE_TEAM_ID }}
binary_name: ${{ env.BINARY_NAME }}
- name: Upload Universal Binary
uses: actions/upload-artifact@v4
with:
name: osquery-mac-universal
path: artifacts/
retention-days: 30
compression-level: 9
build_windows:
name: "Build C Client for (${{ matrix.os }} ${{ matrix.os_arch }})"
runs-on: ${{ matrix.os }}
needs: [version]
if: |
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch'
defaults:
run:
shell: cmd
strategy:
fail-fast: false
matrix:
include:
- name: "Windows x64"
os: windows-2022 # pinned: windows-latest is VS 2026; generator below needs VS 17
os_arch: x64
artifact_name: osquery-windows-amd64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Setup Visual Studio Build Tools
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.os_arch }}
- name: Configure CMake for ${{ matrix.os }}
run: |
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A ${{ matrix.os_arch }} -DOSQUERY_VERSION="${{ needs.version.outputs.version }}" ..
- name: Build OSQuery for Windows ${{ matrix.os_arch }} with MSBuild
run: |
cd build
cmake --build . --config RelWithDebInfo -j10
- name: Sign Windows package
uses: ./.github/steps/sign-windows-package
with:
azure_tenant_id: ${{ secrets.AZURE_TENANT_ID }}
azure_client_id: ${{ secrets.AZURE_CLIENT_ID }}
azure_client_secret: ${{ secrets.AZURE_CLIENT_SECRET }}
signing_endpoint: ${{ secrets.AZURE_SIGNING_ENDPOINT }}
code_signing_account_name: ${{ secrets.AZURE_CODE_SIGNING_ACCOUNT_NAME }}
certificate_profile_name: ${{ secrets.AZURE_CERTIFICATE_PROFILE_NAME }}
binary_path: build/osquery/RelWithDebInfo/${{ env.BINARY_NAME }}.exe
- name: Upload Windows OSQuery artifact
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: "build/osquery/RelWithDebInfo/${{ env.BINARY_NAME }}.exe"
if-no-files-found: warn
retention-days: 30
compression-level: 9
release:
name: "Create Release"
needs: [build_macos, create_universal_macos, build_windows]
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' &&
inputs.version != ''
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
- name: Prepare release artifacts
run: |
set -e
mkdir -p final-artifacts/clients
# macOS
if [ -d "release-artifacts/osquery-mac-universal" ]; then
tar -czf "final-artifacts/clients/osquery-macos-universal.tar.gz" \
-C "release-artifacts/osquery-mac-universal" ${{ env.BINARY_NAME }}
fi
# Windows
if [ -d "release-artifacts/osquery-windows-amd64" ]; then
(cd "release-artifacts/osquery-windows-amd64" && \
zip "${GITHUB_WORKSPACE}/final-artifacts/clients/osquery-windows-amd64.zip" ${{ env.BINARY_NAME }}.exe)
fi
MISSING=""
[ -f "final-artifacts/clients/osquery-macos-universal.tar.gz" ] || MISSING="$MISSING macOS"
[ -f "final-artifacts/clients/osquery-windows-amd64.zip" ] || MISSING="$MISSING Windows"
if [ -n "$MISSING" ]; then
echo "::error::Missing release artifacts:$MISSING"
exit 1
fi
ls -lh final-artifacts/clients/
- name: Generate release header
run: |
cat > RELEASE_HEADER.md <<EOF
## OSQuery Clients
- **macOS** (Universal): \`osquery-macos-universal.tar.gz\`
- **Windows** (amd64): \`osquery-windows-amd64.zip\`
EOF
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.version }}
name: "🦩 ${{ inputs.version }}"
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
body_path: RELEASE_HEADER.md
files: |
final-artifacts/clients/*