Skip to content

Commit

Permalink
Merge pull request #431 from GyulyVGC/dependabot/github_actions/actio…
Browse files Browse the repository at this point in the history
…ns/upload-artifact-4

build(deps): bump actions/upload-artifact from 3 to 4
  • Loading branch information
GyulyVGC authored Jan 12, 2024
2 parents f6dd939 + fab85b5 commit 61a432a
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 225 deletions.
233 changes: 106 additions & 127 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
if: ${{ matrix.os == 'windows' }}
- name: Install Windows dependencies
if: matrix.os == 'windows'
env:
NPCAP_OEM_URL: ${{ secrets.NPCAP_OEM_URL }}
shell: powershell
Expand All @@ -64,45 +64,26 @@ jobs:
Write-Host "::endgroup::"
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
profile: minimal
default: true

- name: Add build targets
if: ${{ matrix.os == 'macos' }}
run: |
rustup target add \
x86_64-apple-darwin \
aarch64-apple-darwin
- name: Add build targets
if: ${{ matrix.os == 'windows' }}
run: |
rustup target add `
i686-pc-windows-msvc `
x86_64-pc-windows-msvc
targets: ${{ matrix.target }}

- name: Install Cross
if: ${{ matrix.os == 'ubuntu' }}
if: matrix.os == 'ubuntu'
run: cargo install cross --git https://github.com/cross-rs/cross

- name: Build binary
if: ${{ matrix.os == 'ubuntu' }}
if: matrix.os == 'ubuntu'
run: cross build --release --target ${{ matrix.target }}

- name: Build binary
if: ${{ matrix.os == 'macos' || matrix.os == 'windows' }}
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}
if: matrix.os == 'macos' || matrix.os == 'windows'
run: cargo build --release --target ${{ matrix.target }}

- name: Upload build artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.os }}
name: build-${{ matrix.os }}-${{ matrix.target }}
path: |
target/*/release/sniffnet
target/*/release/sniffnet.exe
Expand All @@ -113,58 +94,67 @@ jobs:
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@v4

- name: Install dependencies
run: apt update -y && apt install -y curl build-essential
run: apt-get update -y && apt-get install -y curl build-essential

- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
profile: minimal
default: true
targets: ${{ matrix.target }}

- name: Install packaging tools
run: cargo install cargo-deb

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: build-ubuntu
name: build-ubuntu-${{ matrix.target }}
path: target/

- name: Package for Debian-based Linux distros
shell: bash
run: |
targets=(
i686-unknown-linux-gnu
armv7-unknown-linux-gnueabihf
x86_64-unknown-linux-gnu
aarch64-unknown-linux-gnu
)
mkdir artifacts
for target in "${targets[@]}"; do
cargo deb --no-build --no-strip --target $target
mv target/${target}/debian/*.deb artifacts/
done
mv artifacts/sniffnet*amd64.deb artifacts/Sniffnet_LinuxDEB_amd64.deb
mv artifacts/sniffnet*arm64.deb artifacts/Sniffnet_LinuxDEB_arm64.deb
mv artifacts/sniffnet*i386.deb artifacts/Sniffnet_LinuxDEB_i386.deb
mv artifacts/sniffnet*armhf.deb artifacts/Sniffnet_LinuxDEB_armhf.deb
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@v3
uses: actions/upload-artifact@v4
with:
name: deb
name: deb-${{ matrix.arch }}
path: artifacts/
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@v4
Expand All @@ -173,111 +163,109 @@ jobs:
run: dnf update -y && dnf install -y @development-tools patchelf

- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
profile: minimal
default: true
targets: ${{ matrix.target }}

- name: Install packaging tools
run: cargo install cargo-generate-rpm

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: build-ubuntu
name: build-ubuntu-${{ matrix.target }}
path: target/

- name: Package for RPM-based Linux distros
shell: bash
run: |
targets=(
x86_64-unknown-linux-gnu
aarch64-unknown-linux-gnu
)
mkdir artifacts
for target in "${targets[@]}"; do
patchelf --replace-needed libpcap.so.0.8 libpcap.so.1 target/${target}/release/sniffnet
cargo generate-rpm --target $target
mv target/${target}/generate-rpm/*.rpm artifacts/
done
mv artifacts/sniffnet*x86_64.rpm artifacts/Sniffnet_LinuxRPM_x86_64.rpm
mv artifacts/sniffnet*aarch64.rpm artifacts/Sniffnet_LinuxRPM_aarch64.rpm
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@v3
uses: actions/upload-artifact@v4
with:
name: rpm
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@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
uses: dtolnay/rust-toolchain@stable

- name: Install packaging tools
run: |
cargo install toml-cli
brew install create-dmg
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: build-macos
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
targets=(
x86_64-apple-darwin
aarch64-apple-darwin
)
mkdir artifacts
for target in "${targets[@]}"; do
mkdir -p target/${target}/release/bundle/osx/Sniffnet.app/Contents/{MacOS,Resources}
cp resources/packaging/macos/Info.plist \
target/${target}/release/bundle/osx/Sniffnet.app/Contents/
cp resources/packaging/macos/graphics/sniffnet.icns \
target/${target}/release/bundle/osx/Sniffnet.app/Contents/Resources/
chmod +x target/${target}/release/sniffnet
cp target/${target}/release/sniffnet \
target/${target}/release/bundle/osx/Sniffnet.app/Contents/MacOS/
cp resources/packaging/macos/wrapper.sh \
target/${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-${target%%-*}.dmg" \
"target/${target}/release/bundle/osx/"
done
mv artifacts/sniffnet*x86_64.dmg artifacts/Sniffnet_macOS_Intel.dmg
mv artifacts/sniffnet*aarch64.dmg artifacts/Sniffnet_macOS_AppleSilicon.dmg
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@v3
uses: actions/upload-artifact@v4
with:
name: dmg
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: 32-bit
target: i686-pc-windows-msvc
- arch: 64-bit
target: x86_64-pc-windows-msvc

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -294,37 +282,28 @@ jobs:
Write-Host "::endgroup::"
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
profile: minimal
default: true
targets: ${{ matrix.target }}

- name: Install packaging tools
run: cargo install cargo-wix

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: build-windows
name: build-windows-${{ matrix.target }}
path: target/

- name: Package for Microsoft Windows
shell: powershell
run: |
$targets=@(
"i686-pc-windows-msvc",
"x86_64-pc-windows-msvc"
)
New-Item -ItemType Directory -Path artifacts
foreach ($target in $targets)
{
cargo wix --no-build --nocapture --target $target
Move-Item -Path target\wix\sniffnet*x86.msi -Destination .\artifacts\Sniffnet_Windows_32-bit.msi
Move-Item -Path target\wix\sniffnet*x86_64.msi -Destination .\artifacts\Sniffnet_Windows_64-bit.msi
}
cargo wix --no-build --nocapture --target ${{ matrix.target }}
Move-Item -Path target\wix\sniffnet*.msi -Destination .\artifacts\Sniffnet_Windows_${{ matrix.arch }}.msi
- name: Upload package artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: msi
name: msi-${{ matrix.arch }}
path: artifacts/
if-no-files-found: error
Loading

0 comments on commit 61a432a

Please sign in to comment.