Skip to content

Commit

Permalink
Automated build and packaging
Browse files Browse the repository at this point in the history
for Linux, macOS, and Windows
  • Loading branch information
4r7if3x committed May 5, 2023
1 parent 2b65cde commit 057a501
Show file tree
Hide file tree
Showing 30 changed files with 558 additions and 12 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[{.gitignore,*.desktop}]
indent_size = 0

[*.{json,yml,yaml}]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
20 changes: 20 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
* text eol=lf
.* text eol=lf

*.png binary
*.icns binary
*.ico binary
*.ttf binary
*.mp3 binary
*.rtf binary
*.mmdb binary

*.rs diff=rust
*.md diff=markdown

/.github export-ignore
/.design export-ignore
CHANGELOG.md export-ignore
CONTRIBUTING.md export-ignore
CONTRIBUTORS.md export-ignore
CODE_OF_CONDUCT.md export-ignore
119 changes: 119 additions & 0 deletions .github/workflows/build_and_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Build and Package

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build_and_package:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
include:
- os: ubuntu-latest
targets: >-
x86_64-unknown-linux-gnu
i686-unknown-linux-gnu
aarch64-unknown-linux-gnu
armv7-unknown-linux-gnueabihf
build_targets: >-
--target x86_64-unknown-linux-gnu
--target i686-unknown-linux-gnu
--target aarch64-unknown-linux-gnu
--target armv7-unknown-linux-gnueabihf
- os: macOS-latest
targets: >-
x86_64-apple-darwin
aarch64-apple-darwin
build_targets: >-
--target x86_64-apple-darwin
--target aarch64-apple-darwin
- os: windows-latest
targets: >-
x86_64-pc-windows-msvc
i686-pc-windows-msvc
build_targets: >-
--target x86_64-pc-windows-msvc
--target i686-pc-windows-msvc
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: rustfmt, clippy
targets: ${{ matrix.targets }}
default: true

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release ${{ matrix.build_targets }}

- name: Package for Debian-based Linux distros
if: matrix.os == 'ubuntu-latest'
run: |
cargo install cargo-deb
cargo deb
mkdir artifacts
mv target/debian/*.deb artifacts/
- name: Package for RPM-based Linux distros
if: matrix.os == 'ubuntu-latest'
run: |
cargo install cargo-generate-rpm
cargo generate-rpm
mkdir artifacts
mv target/generate-rpm/*.rpm artifacts/
- name: Package Universal DMG for macOS
if: matrix.os == 'macOS-latest'
run: |
cargo install cargo-bundle
cargo bundle --release
lipo -create -output \
target/release/bundle/osx/sniffnet.app/Contents/MacOS/sniffnet \
target/release/x86_64-apple-darwin/sniffnet \
target/release/aarch64-apple-darwin/sniffnet
brew install create-dmg
mkdir artifacts
create-dmg \
--volname "Sniffnet Installer" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--app-drop-link 600 185 \
--icon "target/release/bundle/osx/sniffnet.app" 200 185 \
--hide-extension "target/release/bundle/osx/sniffnet.app" \
--app-drop-link 600 185 artifacts/sniffnet-universal.dmg target/release/bundle/osx/sniffnet.app
- name: Package MSI for Windows
if: matrix.os == 'windows-latest'
run: |
cargo install cargo-wix
cargo wix main.wxs
mkdir artifacts
mv target/wix/*.msi artifacts/
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}-artifacts
path: artifacts/

- name: Download artifacts
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/download-artifact@v2
with:
path: artifacts/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# TODO: Needs cleanup!

# Created by https://www.toptal.com/developers/gitignore/api/rust,clion,windows,osx,linux,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,clion,windows,osx,linux,macos

Expand Down
92 changes: 80 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,94 @@
[package]
name = "sniffnet"
version = "1.1.4"
authors = ["Giuliano Bellini"]
edition = "2021"
name = "sniffnet"
version = "1.1.4"
authors = [ "Giuliano Bellini" ]
edition = "2021"
description = "Application to comfortably monitor your network traffic"
readme = "README.md"
repository = "https://github.com/GyulyVGC/sniffnet"
license = "MIT OR Apache-2.0"
keywords = ["filter", "network", "packet", "sniffer", "gui"]
categories = ["visualization", "gui", "network-programming"]
include = ["src/**/*", "LICENSE-*", "README.md", "CHANGELOG.md", "resources/countries_flags/**/*", "resources/DB/GeoLite2-Country.mmdb", "resources/palettes/*", "resources/fonts/subset/*", "resources/sounds/*"]
readme = "README.md"
repository = "https://github.com/GyulyVGC/sniffnet"
license = "MIT OR Apache-2.0"
keywords = [ "filter", "network", "packet", "sniffer", "gui" ]
categories = [ "visualization", "gui", "network-programming" ]
include = [
"src/**/*",
"LICENSE-*",
"README.md",
"CHANGELOG.md",
"resources/countries_flags/**/*",
"resources/DB/GeoLite2-Country.mmdb",
"resources/palettes/*",
"resources/fonts/subset/*",
"resources/sounds/*"
]

#═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════

[package.metadata.deb]
assets = [
["target/release/sniffnet", "/usr/bin/", "755"],
["resources/sniffnet.desktop", "/usr/share/applications/", "644"],
["resources/icons/sniffnet-linux_8x8.png", "/usr/share/icons/hicolor/8x8/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_16x16.png", "/usr/share/icons/hicolor/16x16/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_22x22.png", "/usr/share/icons/hicolor/22x22/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_24x24.png", "/usr/share/icons/hicolor/24x24/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_32x32.png", "/usr/share/icons/hicolor/32x32/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_36x36.png", "/usr/share/icons/hicolor/36x36/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_42x42.png", "/usr/share/icons/hicolor/42x42/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_48x48.png", "/usr/share/icons/hicolor/48x48/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_64x64.png", "/usr/share/icons/hicolor/64x64/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_72x72.png", "/usr/share/icons/hicolor/72x72/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_96x96.png", "/usr/share/icons/hicolor/96x96/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_128x128.png", "/usr/share/icons/hicolor/128x128/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_160x160.png", "/usr/share/icons/hicolor/160x160/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_192x192.png", "/usr/share/icons/hicolor/192x192/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_256x256.png", "/usr/share/icons/hicolor/256x256/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_384x384.png", "/usr/share/icons/hicolor/384x384/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_512x512.png", "/usr/share/icons/hicolor/512x512/apps/sniffnet.png", "644"],
["resources/icons/sniffnet-linux_1024x1024.png", "/usr/share/icons/hicolor/1024x1024/apps/sniffnet.png", "644"]
]

#───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

[package.metadata.generate-rpm]
assets = [
{ source = "target/release/sniffnet", dest = "/usr/bin/", mode = "755" },
{ source = "resources/sniffnet.desktop", dest = "/usr/share/applications/", mode = "644" },
{ source = "resources/icons/sniffnet-linux_8x8.png", dest = "/usr/share/icons/hicolor/8x8/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_16x16.png", dest = "/usr/share/icons/hicolor/16x16/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_22x22.png", dest = "/usr/share/icons/hicolor/22x22/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_24x24.png", dest = "/usr/share/icons/hicolor/24x24/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_32x32.png", dest = "/usr/share/icons/hicolor/32x32/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_36x36.png", dest = "/usr/share/icons/hicolor/36x36/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_42x42.png", dest = "/usr/share/icons/hicolor/42x42/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_48x48.png", dest = "/usr/share/icons/hicolor/48x48/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_64x64.png", dest = "/usr/share/icons/hicolor/64x64/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_72x72.png", dest = "/usr/share/icons/hicolor/72x72/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_96x96.png", dest = "/usr/share/icons/hicolor/96x96/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_128x128.png", dest = "/usr/share/icons/hicolor/128x128/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_160x160.png", dest = "/usr/share/icons/hicolor/160x160/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_192x192.png", dest = "/usr/share/icons/hicolor/192x192/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_256x256.png", dest = "/usr/share/icons/hicolor/256x256/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_384x384.png", dest = "/usr/share/icons/hicolor/384x384/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_512x512.png", dest = "/usr/share/icons/hicolor/512x512/apps/sniffnet.png", mode = "644" },
{ source = "resources/icons/sniffnet-linux_1024x1024.png", dest = "/usr/share/icons/hicolor/1024x1024/apps/sniffnet.png", mode = "644" }
]

#───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

[package.metadata.bundle]
name = "Sniffnet"
identifier = "gyulyvgc.sniffnet"
icon = ["./resources/logos/icon.ico"]
icon = [
"resources/icons/sniffnet-macos.icns"
]

#═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════

[profile.release]
opt-level = 3
lto = true
strip = true

#═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════

[dependencies]
pcap = "1.0.0"
Expand All @@ -41,5 +107,7 @@ serde = { version = "1.0.160", default_features = false, features = ["derive"] }
rodio = { version = "0.17.1", default_features = false, features = ["mp3"] }
reqwest = { version = "0.11.17", features = ["json", "blocking"] }

#───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

[dev-dependencies]
rstest = "0.17.0"
Loading

0 comments on commit 057a501

Please sign in to comment.