forked from seladb/PcapPlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
334 lines (283 loc) · 10.4 KB
/
package.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
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
name: Package and release
on:
push:
tags:
- '*'
pull_request:
paths:
# Also run this workflow when this package.yml is update by a PR
- '.github/workflows/package.yml'
env:
BUILD_DIR: Dist
jobs:
linux:
runs-on: ubuntu-latest
container: seladb/${{ matrix.image }}
strategy:
matrix:
include:
- image: ubuntu2204
config-zstd: OFF
- image: ubuntu2204-icpx
config-zstd: OFF
additional-flags: -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx
- image: ubuntu2004
config-zstd: OFF
- image: ubuntu1804
config-zstd: OFF
- image: rhel93
config-zstd: OFF
- image: fedora37
config-zstd: OFF
- image: alpine317
config-zstd: OFF
steps:
- name: Checkout code
uses: actions/checkout@v3
# Checkout is performed out of the container and doesn't match our user
- name: Fix checkout ownership
run: chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE"
- name: Setup Intel Compiler variables
if: contains(matrix.image, 'icpx')
run: |
. /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
- name: Debug Cmake
run: cmake --system-information
- name: Configure PcapPlusPlus
run: cmake -DPCAPPP_PACKAGE=ON -DLIGHT_PCAPNG_ZSTD=${{ matrix.config-zstd }} ${{ matrix.additional-flags }} -S . -B "$BUILD_DIR"
- name: Build PcapPlusPlus
run: cmake --build "$BUILD_DIR" -j
- name: Package
run: cmake --build "$BUILD_DIR" --target package
- name: Generate hashes
run: |
echo "::set-output name=hashes::$(sha256sum ${{ env.BUILD_DIR }}/*.tar.gz ${{ env.BUILD_DIR }}/*.deb ${{ env.BUILD_DIR }}/*.rpm | base64 -w0)"
- name: Upload binaries to release
uses: ncipollo/release-action@v1
with:
draft: true
allowUpdates: true
updateOnlyUnreleased: true
artifacts: "${{ env.BUILD_DIR }}/*.tar.gz,${{ env.BUILD_DIR }}/*.deb,${{ env.BUILD_DIR }}/*.rpm"
provenance:
needs: [linux]
permissions:
actions: read
id-token: write
contents: write
- name: Generate provenance
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
base64-subjects: "${{ needs.build.outputs.hashes }}"
upload-assets: true
freebsd:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- freebsd-version: "13.2"
- freebsd-version: "14.0"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Test in FreeBSD
uses: vmactions/freebsd-vm@v1
with:
release: ${{ matrix.freebsd-version }}
envs: 'BUILD_DIR'
usesh: true
prepare: |
pkg install -y bash cmake git-tiny gmake gsed libpcap py39-pip
run: |
cmake -DPCAPPP_PACKAGE=ON -S . -B "$BUILD_DIR"
cmake --build "$BUILD_DIR" -j 4
cmake --build "$BUILD_DIR" --target package
- name: Upload binaries to release
if: github.ref_type == 'tag'
uses: ncipollo/release-action@v1
with:
draft: true
allowUpdates: true
updateOnlyUnreleased: true
artifacts: ${{ env.BUILD_DIR }}/*.tar.gz
macos:
runs-on: macos-12
strategy:
matrix:
xcode-version: [14.2.0, 13.4.1]
arch: [x86_64, arm64]
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "${{ matrix.xcode-version }}"
- name: Checkout code
uses: actions/checkout@v3
- name: Configure PcapPlusPlus
run: |
cmake -DPCAPPP_PACKAGE=ON -DLIGHT_PCAPNG_ZSTD=${{ matrix.config-zstd }} -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} -S . -B "$BUILD_DIR"
- name: Build PcapPlusPlus
run: cmake --build "$BUILD_DIR" -j
- name: Package
run: cmake --build "$BUILD_DIR" --target package
- name: Upload binaries to release
if: github.ref_type == 'tag'
uses: ncipollo/release-action@v1
with:
draft: true
allowUpdates: true
updateOnlyUnreleased: true
artifacts: "${{ env.BUILD_DIR }}/*.tar.gz,${{ env.BUILD_DIR }}/*.pkg"
mingw-w64:
runs-on: windows-latest
strategy:
matrix:
include:
- env: i686
sys: mingw32
- env: x86_64
sys: mingw64
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
update: true
install: >-
git
mingw-w64-${{matrix.env}}-cmake
mingw-w64-${{matrix.env}}-gcc
mingw-w64-${{matrix.env}}-make
- name: Install NPcap
env:
NPCAP_USERNAME: ${{ secrets.NPCAP_USERNAME }}
NPCAP_PASSWORD: ${{ secrets.NPCAP_PASSWORD }}
run: |
ci\install_npcap.bat
echo "PCAP_SDK_DIR=/C/Npcap-sdk" >> $env:GITHUB_ENV
- name: Configure PcapPlusPlus
shell: msys2 {0}
run: |
cmake -G "MinGW Makefiles" -DPCAP_ROOT=/C/Npcap-sdk -DLIGHT_PCAPNG_ZSTD=OFF -DPCAPPP_PACKAGE=ON -S . -B "$BUILD_DIR"
- name: Debug Cmake
shell: msys2 {0}
run: cmake --system-information
- name: Build PcapPlusPlus
shell: msys2 {0}
# More than 2 jobs would make the build crash with OOM
# cc1plus.exe: out of memory allocating 65536 bytes
run: cmake --build "$BUILD_DIR" -j 2
- name: Package
shell: msys2 {0}
run: cmake --build "$BUILD_DIR" --target package
- name: Upload binaries to release
if: github.ref_type == 'tag'
uses: ncipollo/release-action@v1
with:
draft: true
allowUpdates: true
updateOnlyUnreleased: true
artifacts: ${{ env.BUILD_DIR }}/*.zip
visual-studio:
strategy:
matrix:
os: [ windows-2019, windows-2022 ]
arch: [ Win32, x64 ]
configuration: [ Debug, Release ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Install WinPcap
run: |
ci\install_winpcap.bat
echo "PCAP_SDK_DIR=C:\WpdPack" >> $env:GITHUB_ENV
- name: Configure PcapPlusPlus
run: |
$platform = if ("${{ matrix.os }}" -eq "windows-2019") { "Visual Studio 16 2019" } else { "Visual Studio 17 2022" }
cmake -A ${{ matrix.arch }} -G "$platform" -DPCAP_ROOT=${{ env.PCAP_SDK_DIR }} -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DPCAPPP_PACKAGE=ON -S . -B "$env:BUILD_DIR"
- name: Build PcapPlusPlus
run: cmake --build $env:BUILD_DIR --config ${{ matrix.configuration }} -j
- name: Package
run: cmake --build "$env:BUILD_DIR" --config ${{ matrix.configuration }} --target package
- name: Upload binaries to release
if: github.ref_type == 'tag'
uses: ncipollo/release-action@v1
with:
draft: true
allowUpdates: true
updateOnlyUnreleased: true
artifacts: ${{ env.BUILD_DIR }}/*.zip
android-build:
strategy:
matrix:
include:
- target: "armeabi-v7a"
api-version: 30
- target: "x86"
api-version: 30
- target: "arm64-v8a"
api-version: 30
- target: "x86_64"
api-version: 30
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout lipbcap for Android
uses: actions/checkout@main
with:
repository: seladb/libpcap-android
path: ./libpcap-android
- name: Configure and Build PcapPlusPlus
run: |
LIBPCAP_PATH="$(pwd)/libpcap-android"
export LIB_DIR="${{ matrix.target }}/${{ matrix.api-version }}"
export LOCAL_BUILD_DIR="${BUILD_DIR}/${LIB_DIR}"
cmake -DPCAPPP_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_LIBDIR="${LIB_DIR}" -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_PLATFORM="${{ matrix.api-version }}" -DANDROID_ABI="${{ matrix.target }}" -DPCAP_INCLUDE_DIR="${LIBPCAP_PATH}/include/" -DPCAP_LIBRARY="${LIBPCAP_PATH}/${{ matrix.target }}/${{ matrix.api-version}}/libpcap.a" -DPCAPPP_PACKAGE=ON -S . -B "$LOCAL_BUILD_DIR"
cmake --build "$LOCAL_BUILD_DIR" -j --target package
- name: Prepare package
run: |
export LOCAL_BUILD_DIR="${BUILD_DIR}/${{ matrix.target }}/${{ matrix.api-version }}"
export PACKAGE_FILE=$(ls ${LOCAL_BUILD_DIR} | grep pcapplusplus)
export PACKAGE_DIR=$(basename ${PACKAGE_FILE%} .tar.gz)
export COMBINED_PACKAGE_DIR=$(echo "$PACKAGE_DIR" | cut -f1,2,3 -d'-')
tar -xvf "${LOCAL_BUILD_DIR}/${PACKAGE_FILE}"
mv "${PACKAGE_DIR}" "${COMBINED_PACKAGE_DIR}"
find . -name example-app -type d -exec rm -r {} +
find . -name cmake -type d -exec rm -r {} +
find . -name pkgconfig -type d -exec rm -r {} +
mv ${COMBINED_PACKAGE_DIR}/include/pcapplusplus/* "${COMBINED_PACKAGE_DIR}/include/"
rmdir "${COMBINED_PACKAGE_DIR}/include/pcapplusplus/"
mkdir -p "android-package"
mv "${COMBINED_PACKAGE_DIR}" "android-package"
- uses: actions/upload-artifact@v4
with:
path: android-package
name: android-package-${{ matrix.target }}-${{ matrix.api-version }}
if-no-files-found: error
android-package:
needs: android-build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: android-package-*
merge-multiple: true
- name: Package into archive
run: |
export PACKAGE_DIR=$(ls | grep pcapplusplus)
echo "PACKAGE_DIR=$PACKAGE_DIR" >> $GITHUB_ENV
tar cvf "${PACKAGE_DIR}.tar.gz" "${PACKAGE_DIR}"
- name: Upload binaries to release
if: github.ref_type == 'tag'
uses: ncipollo/release-action@v1
with:
draft: true
allowUpdates: true
updateOnlyUnreleased: true
artifacts: ${{ env.PACKAGE_DIR }}.tar.gz