-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
412 lines (356 loc) · 13 KB
/
package.yml
File metadata and controls
412 lines (356 loc) · 13 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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
name: Package
permissions:
contents: read
on:
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu
arch: i386
target: i686-unknown-linux-gnu
- os: ubuntu
arch: armhf
target: armv7-unknown-linux-gnueabihf
- os: ubuntu
arch: amd64
target: x86_64-unknown-linux-gnu
- os: ubuntu
arch: arm64
target: aarch64-unknown-linux-gnu
- os: macos
arch: amd64
target: x86_64-apple-darwin
- os: macos
arch: arm64
target: aarch64-apple-darwin
- os: windows
arch: i386
target: i686-pc-windows-msvc
- os: windows
arch: amd64
target: x86_64-pc-windows-msvc
- os: windows
arch: arm64
target: aarch64-pc-windows-msvc
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Linux dependencies
if: matrix.os == 'ubuntu'
run: sudo apt-get update -y && sudo apt-get install -y libpcap-dev libasound2-dev libgtk-3-dev
- name: Install Windows dependencies
if: matrix.os == 'windows'
env:
NPCAP_OEM_URL: ${{ secrets.NPCAP_OEM_URL }}
shell: powershell
run: |
Write-Host "::group::Npcap SDK"
$ARCH = "${{ matrix.arch }}"
Invoke-WebRequest -Uri "https://npcap.com/dist/npcap-sdk-1.13.zip" -OutFile "$env:TEMP\npcap-sdk.zip" -Verbose
Expand-Archive -LiteralPath "$env:TEMP\npcap-sdk.zip" -DestinationPath "$env:TEMP\npcap-sdk" -Verbose
$LibPath = switch ($ARCH)
{
"i386" { "Lib" }
"amd64" { "Lib\x64" }
"arm64" { "Lib\ARM64" }
default { throw "$ARCH is not supported!" }
}
Add-Content -Path "$env:GITHUB_ENV" -Value "LIB=$env:TEMP\npcap-sdk\$LibPath"
Write-Host "::endgroup::"
Write-Host "::group::Npcap DLL"
Invoke-WebRequest -Uri "$env:NPCAP_OEM_URL" -OutFile "$env:TEMP\npcap-oem.exe" -Verbose
Start-Process -FilePath "$env:TEMP\npcap-oem.exe" -ArgumentList "/S" -Wait
Write-Host "::endgroup::"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Check crate
if: matrix.os == 'macos' || matrix.os == 'windows' || matrix.os == 'ubuntu' && matrix.arch == 'amd64'
run: cargo publish --dry-run --target ${{ matrix.target }}
- name: Clippy (release mode)
run: cargo clippy --release -- -D warnings
- name: Test (release mode)
if: matrix.os == 'macos' || matrix.os == 'ubuntu' || matrix.os == 'windows' && matrix.arch == 'amd64'
run: |
cargo test --release --verbose -- --nocapture &&
cargo clean
- name: Install Cross
if: matrix.os == 'ubuntu'
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build binary (Linux)
if: matrix.os == 'ubuntu'
run: cross build --release --target ${{ matrix.target }}
- name: Build binary (macOS/Windows)
if: matrix.os == 'macos' || matrix.os == 'windows'
run: cargo build --release --target ${{ matrix.target }}
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: build-${{ matrix.os }}-${{ matrix.target }}
path: |
target/*/release/sniffnet
target/*/release/sniffnet.exe
if-no-files-found: error
deb:
runs-on: ubuntu-latest
container:
image: debian:latest
needs: build
strategy:
fail-fast: true
matrix:
include:
- target: i686-unknown-linux-gnu
arch: i386
- target: armv7-unknown-linux-gnueabihf
arch: armhf
- target: x86_64-unknown-linux-gnu
arch: amd64
- target: aarch64-unknown-linux-gnu
arch: arm64
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install dependencies
run: apt-get update -y && apt-get install -y curl build-essential
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install packaging tools
run: cargo install cargo-deb
- uses: actions/download-artifact@v8
with:
name: build-ubuntu-${{ matrix.target }}
path: target/
- name: Package for Debian-based Linux distros
shell: bash
run: |
mkdir artifacts
cargo deb --no-build --no-strip --target ${{ matrix.target }}
mv target/${{ matrix.target }}/debian/*.deb artifacts/Sniffnet_LinuxDEB_${{ matrix.arch }}.deb
- name: Upload package artifacts
uses: actions/upload-artifact@v7
with:
name: deb-${{ matrix.arch }}
path: artifacts/
if-no-files-found: error
appimage:
runs-on: ubuntu-latest
container:
image: debian:latest
options: --privileged
needs: deb
strategy:
fail-fast: true
matrix:
include:
- arch: amd64
appimgarch: x86_64
- arch: arm64
appimgarch: aarch64
- arch: i386
appimgarch: i686
- arch: armhf
appimgarch: armhf
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install dependencies
run: apt-get update -y && apt-get install -y git build-essential graphicsmagick-imagemagick-compat wget file desktop-file-utils libfuse2
- name: Download Debian package
uses: actions/download-artifact@v8
with:
name: deb-${{ matrix.arch }}
path: /target/
- name: Download pkg2appimage
shell: bash
run: git clone https://github.com/AppImageCommunity/pkg2appimage.git
- name: Replace placeholders
shell: bash
run: |
sed -i -e 's/REPLACE_TAG/Sniffnet_LinuxDEB_${{ matrix.arch }}.deb/g' resources/packaging/linux/AppImage/sniffnet.yml
sed -i -e 's/binary-${arch}/binary-${{ matrix.arch }}/g' pkg2appimage/functions.sh
- name: Repackage for AppImage
shell: bash
run: |
cd pkg2appimage
ARCH=${{ matrix.appimgarch }} FUNCTIONS_SH=$(pwd)/functions.sh ./pkg2appimage ../resources/packaging/linux/AppImage/sniffnet.yml
mkdir /out
mv out/*.AppImage /out/Sniffnet_LinuxAppImage_${{ matrix.arch }}.AppImage
- name: Upload package artifacts
uses: actions/upload-artifact@v7
with:
name: appimage-${{ matrix.arch }}
path: /out/
if-no-files-found: error
rpm:
runs-on: ubuntu-latest
container:
image: fedora:latest
needs: build
strategy:
fail-fast: true
matrix:
include:
- arch: x86_64
target: x86_64-unknown-linux-gnu
- arch: aarch64
target: aarch64-unknown-linux-gnu
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install dependencies
run: dnf update -y && dnf install -y @development-tools patchelf
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install packaging tools
run: cargo install cargo-generate-rpm
- uses: actions/download-artifact@v8
with:
name: build-ubuntu-${{ matrix.target }}
path: target/
- name: Package for RPM-based Linux distros
shell: bash
run: |
mkdir artifacts
patchelf --replace-needed libpcap.so.0.8 libpcap.so.1 target/${{ matrix.target }}/release/sniffnet
cargo generate-rpm --target ${{ matrix.target }}
mv target/${{ matrix.target }}/generate-rpm/*.rpm artifacts/Sniffnet_LinuxRPM_${{ matrix.arch }}.rpm
- name: Upload package artifacts
uses: actions/upload-artifact@v7
with:
name: rpm-${{ matrix.arch }}
path: artifacts/
if-no-files-found: error
dmg:
runs-on: macos-latest
needs: build
strategy:
fail-fast: true
matrix:
include:
- arch: Intel
target: x86_64-apple-darwin
- arch: AppleSilicon
target: aarch64-apple-darwin
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install packaging tools
run: |
cargo install toml-cli
brew install create-dmg
- uses: actions/download-artifact@v8
with:
name: build-macos-${{ matrix.target }}
path: target/
- name: Package for macOS
shell: bash
run: |
VERSION=$(toml get Cargo.toml package.version --raw)
sed -i'.bak' -e "s/0\.0\.0/${VERSION}/g" -e "s/fffffff/${GITHUB_SHA:0:7}/g" resources/packaging/macos/Info.plist
mkdir artifacts
mkdir -p target/release/bundle/osx/Sniffnet.app/Contents/{MacOS,Resources}
cp resources/packaging/macos/Info.plist \
target/release/bundle/osx/Sniffnet.app/Contents/
cp resources/packaging/macos/graphics/sniffnet.icns \
target/release/bundle/osx/Sniffnet.app/Contents/Resources/
chmod +x target/${{ matrix.target }}/release/sniffnet
cp target/${{ matrix.target }}/release/sniffnet \
target/release/bundle/osx/Sniffnet.app/Contents/MacOS/
cp resources/packaging/macos/wrapper.sh \
target/release/bundle/osx/Sniffnet.app/Contents/MacOS/
create-dmg \
--volname "Sniffnet Installer" \
--background "resources/packaging/macos/graphics/dmg_bg.png" \
--window-pos 200 120 \
--window-size 900 450 \
--icon-size 100 \
--app-drop-link 620 240 \
--icon "Sniffnet.app" 300 240 \
--hide-extension "Sniffnet.app" \
"artifacts/Sniffnet_macOS_${{ matrix.arch }}.dmg" \
"target/release/bundle/osx/"
- name: Upload package artifacts
uses: actions/upload-artifact@v7
with:
name: dmg-${{ matrix.arch }}
path: artifacts/
if-no-files-found: error
msi:
runs-on: windows-latest
needs: build
strategy:
fail-fast: true
matrix:
include:
- arch: x86
target: i686-pc-windows-msvc
- arch: x64
target: x86_64-pc-windows-msvc
- arch: arm64
target: aarch64-pc-windows-msvc
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install dependencies
shell: powershell
run: |
Write-Host "::group::WiX Toolset"
Invoke-WebRequest `
-Uri "https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip" `
-OutFile "$env:TEMP\wix-binaries.zip" -Verbose
Expand-Archive -LiteralPath "$env:TEMP\wix-binaries.zip" -DestinationPath "$env:TEMP\wix" -Verbose
Set-Item -Path env:Path -Value "$env:Path;$env:TEMP\wix"
Write-Host "::endgroup::"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install packaging tools
run: cargo install cargo-wix
- uses: actions/download-artifact@v8
with:
name: build-windows-${{ matrix.target }}
path: target/
- name: Package for Microsoft Windows
shell: powershell
run: |
New-Item -ItemType Directory -Path artifacts
cargo wix --no-build --nocapture --target ${{ matrix.target }}
Move-Item -Path target\wix\sniffnet*.msi -Destination .\artifacts\Sniffnet_Windows_${{ matrix.arch }}.msi
- name: Upload unsigned package artifacts
id: upload-unsigned-artifact
uses: actions/upload-artifact@v7
with:
name: msi-${{ matrix.arch }}
path: artifacts/
if-no-files-found: error
- name: Sign package artifacts
uses: signpath/github-action-submit-signing-request@v2.2
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: '3b533e02-73c3-4908-a018-d09a34498a6a'
project-slug: 'sniffnet'
signing-policy-slug: 'release-signing'
github-artifact-id: '${{ steps.upload-unsigned-artifact.outputs.artifact-id }}'
wait-for-completion: true
output-artifact-directory: './artifacts'
- name: Upload signed package artifacts (overwrite unsigned)
uses: actions/upload-artifact@v7
with:
name: msi-${{ matrix.arch }}
path: artifacts/
if-no-files-found: error
overwrite: true