- Build pipeline: checkout, system deps, Rust nightly, bpf-linker, release build - Produces .deb and .rpm packages via cargo-deb and cargo-generate-rpm - Cargo caching for registry, binaries, and build artifacts - Triggers on push to any branch and version tags Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
128 lines
4.2 KiB
YAML
128 lines
4.2 KiB
YAML
name: Build & Package
|
|
|
|
# Build tcptop binary and produce .deb/.rpm packages
|
|
on:
|
|
push:
|
|
branches: ["*"]
|
|
tags: ["v*"]
|
|
|
|
jobs:
|
|
build:
|
|
# NOTE: Adjust the runner label to match your Gitea runner configuration.
|
|
# Common labels: "linux", "ubuntu-latest", "debian", or a custom label.
|
|
runs-on: linux
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
# Ensure cargo binaries are on PATH for all steps
|
|
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${{ runner.home }}/.cargo/bin
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
# Cache Cargo registry, git checkouts, installed binaries, and build artifacts
|
|
# to avoid re-downloading and re-compiling on every run.
|
|
- name: Cache Cargo artifacts
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
~/.cargo/bin
|
|
target
|
|
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
cargo-${{ runner.os }}-
|
|
|
|
- name: Install system dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
build-essential \
|
|
pkg-config \
|
|
linux-headers-$(uname -r) \
|
|
libelf-dev \
|
|
clang \
|
|
llvm \
|
|
rpm
|
|
# build-essential: gcc, make, etc. for native compilation
|
|
# pkg-config: locates system libraries during cargo build
|
|
# linux-headers: kernel headers for eBPF program compilation
|
|
# libelf-dev: ELF parsing library required by eBPF toolchain
|
|
# clang + llvm: LLVM backend used by bpf-linker to compile eBPF bytecode
|
|
# rpm: needed by cargo-generate-rpm to build .rpm packages
|
|
shell: bash
|
|
|
|
- name: Install Rust toolchain
|
|
run: |
|
|
# Install rustup if not already present (bare runners may not have it)
|
|
if ! command -v rustup &> /dev/null; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
|
|
source "$HOME/.cargo/env"
|
|
fi
|
|
# rust-toolchain.toml in the repo root will auto-select the pinned
|
|
# nightly (nightly-2026-03-20) with rust-src, rustfmt, clippy on
|
|
# the first cargo invocation. Just verify it works:
|
|
rustc --version
|
|
cargo --version
|
|
shell: bash
|
|
|
|
- name: Install bpf-linker
|
|
run: |
|
|
# bpf-linker is the LLVM-based linker for eBPF object files.
|
|
# Skip install if already cached.
|
|
if ! command -v bpf-linker &> /dev/null; then
|
|
cargo install bpf-linker
|
|
fi
|
|
bpf-linker --version || true
|
|
shell: bash
|
|
|
|
- name: Install packaging tools
|
|
run: |
|
|
# cargo-deb: builds Debian .deb packages from Cargo metadata
|
|
# cargo-generate-rpm: builds RPM packages from Cargo metadata
|
|
if ! command -v cargo-deb &> /dev/null; then
|
|
cargo install cargo-deb
|
|
fi
|
|
if ! command -v cargo-generate-rpm &> /dev/null; then
|
|
cargo install cargo-generate-rpm
|
|
fi
|
|
shell: bash
|
|
|
|
- name: Build release binary
|
|
run: |
|
|
# build.rs in the tcptop crate auto-compiles the tcptop-ebpf
|
|
# program via aya-build before linking the userspace binary.
|
|
cargo build --release -p tcptop
|
|
shell: bash
|
|
|
|
- name: Build .deb package
|
|
run: |
|
|
# --no-build: binary already compiled in the previous step
|
|
cargo deb -p tcptop --no-build
|
|
shell: bash
|
|
|
|
- name: Build .rpm package
|
|
run: |
|
|
cargo generate-rpm -p tcptop
|
|
shell: bash
|
|
|
|
- name: List built packages
|
|
run: |
|
|
echo "=== Built packages ==="
|
|
ls -lh target/debian/tcptop_*.deb
|
|
ls -lh target/generate-rpm/tcptop-*.rpm
|
|
shell: bash
|
|
|
|
# TODO: Add artifact upload action when available on your Gitea instance.
|
|
# Example (if using a compatible action):
|
|
#
|
|
# - name: Upload packages
|
|
# uses: actions/upload-artifact@v3
|
|
# with:
|
|
# name: tcptop-packages
|
|
# path: |
|
|
# target/debian/tcptop_*.deb
|
|
# target/generate-rpm/tcptop-*.rpm
|