Some checks failed
Build & Package / build (push) Has been cancelled
Binaries built on Debian Bookworm (glibc 2.36) require GLIBC_2.29+, which isn't available on AlmaLinux 8 (glibc 2.28). Switch to cargo-zigbuild with an explicit glibc 2.28 target so the RPM works on RHEL 8 / AlmaLinux 8 without requiring a newer glibc. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
177 lines
6.1 KiB
YAML
177 lines
6.1 KiB
YAML
name: Build & Package
|
|
|
|
# Build tcptop binary and produce .deb/.rpm packages
|
|
on:
|
|
push:
|
|
branches: ["*"]
|
|
tags: ["v*"]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: linux
|
|
# Run in a Debian container so bpf-linker can load the LLVM shared lib
|
|
# from the Rust toolchain (Alpine/musl statically links LLVM, breaking
|
|
# aya-rustc-llvm-proxy's dlopen).
|
|
container:
|
|
image: debian:bookworm
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
DEBIAN_FRONTEND: noninteractive
|
|
|
|
steps:
|
|
- name: Install system dependencies
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y \
|
|
build-essential \
|
|
pkg-config \
|
|
linux-headers-amd64 \
|
|
libelf-dev \
|
|
clang \
|
|
llvm \
|
|
rpm \
|
|
curl \
|
|
git \
|
|
nodejs
|
|
# build-essential: gcc, make, etc. for native compilation
|
|
# pkg-config: locates system libraries during cargo build
|
|
# linux-headers-amd64: 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: Checkout code
|
|
run: |
|
|
git clone --depth=1 --branch="${GITHUB_REF_NAME}" \
|
|
"${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" .
|
|
shell: bash
|
|
|
|
- name: Install Rust toolchain
|
|
run: |
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
|
|
. "$HOME/.cargo/env"
|
|
# Install the pinned nightly from rust-toolchain.toml
|
|
rustup toolchain install nightly-2026-03-20 --component rust-src,rustfmt,clippy
|
|
# aya-build invokes `cargo +nightly` to compile eBPF programs
|
|
rustup toolchain install nightly --component rust-src
|
|
rustc --version
|
|
cargo --version
|
|
shell: bash
|
|
|
|
- name: Install bpf-linker
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
if ! command -v bpf-linker &> /dev/null; then
|
|
cargo install bpf-linker
|
|
fi
|
|
bpf-linker --version || true
|
|
shell: bash
|
|
|
|
- name: Install packaging tools
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
if ! command -v cargo-zigbuild &> /dev/null; then
|
|
cargo install cargo-zigbuild
|
|
fi
|
|
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: Install zig (for cross-glibc linking)
|
|
run: |
|
|
ZIG_VERSION="0.14.1"
|
|
curl -sSfL "https://ziglang.org/download/${ZIG_VERSION}/zig-linux-x86_64-${ZIG_VERSION}.tar.xz" | tar -xJ
|
|
mv "zig-linux-x86_64-${ZIG_VERSION}" /opt/zig
|
|
echo "/opt/zig" >> "$GITHUB_PATH"
|
|
export PATH="/opt/zig:$PATH"
|
|
zig version
|
|
shell: bash
|
|
|
|
- name: Build release binary
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
export PATH="/opt/zig:$PATH"
|
|
# build.rs auto-compiles the eBPF program via aya-build (normal cargo)
|
|
# zigbuild links the userspace binary against glibc 2.28 for RHEL 8 / AlmaLinux 8 compat
|
|
cargo zigbuild --release -p tcptop --target x86_64-unknown-linux-gnu.2.28
|
|
shell: bash
|
|
|
|
- name: Build .deb package
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
# --no-build: binary already compiled in the previous step
|
|
cargo deb -p tcptop --no-build --target x86_64-unknown-linux-gnu
|
|
shell: bash
|
|
|
|
- name: Build .rpm package
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
# cargo-generate-rpm looks in target/<triple>/release by default when --target is set
|
|
cargo generate-rpm -p tcptop --target x86_64-unknown-linux-gnu
|
|
shell: bash
|
|
|
|
- name: Collect packages
|
|
run: |
|
|
mkdir -p dist
|
|
cp target/x86_64-unknown-linux-gnu/debian/tcptop_*.deb dist/
|
|
cp target/x86_64-unknown-linux-gnu/generate-rpm/tcptop-*.rpm dist/
|
|
echo "=== Built packages ==="
|
|
ls -lh dist/
|
|
shell: bash
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: tcptop-packages
|
|
path: dist/*
|
|
|
|
- name: Create release
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
TAG="${GITHUB_REF_NAME}"
|
|
API_URL="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
|
|
|
# Use GITEA_TOKEN secret if available, fall back to GITHUB_TOKEN
|
|
TOKEN="${GITEA_TOKEN:-${GITHUB_TOKEN}}"
|
|
|
|
echo "Creating release for ${TAG}..."
|
|
RESPONSE=$(curl -sf -X POST \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${TAG}\", \"body\": \"tcptop ${TAG}\"}" \
|
|
"${API_URL}/releases") || {
|
|
echo "Failed to create release. Response:"
|
|
curl -X POST \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${TAG}\", \"body\": \"tcptop ${TAG}\"}" \
|
|
"${API_URL}/releases"
|
|
exit 1
|
|
}
|
|
|
|
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
|
echo "Release created with ID: ${RELEASE_ID}"
|
|
|
|
# Attach packages to the release
|
|
for f in dist/*; do
|
|
echo "Uploading $(basename "$f")..."
|
|
curl -sf -X POST \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-F "attachment=@${f}" \
|
|
"${API_URL}/releases/${RELEASE_ID}/assets?name=$(basename "$f")" || {
|
|
echo "Failed to upload $(basename "$f")"
|
|
exit 1
|
|
}
|
|
done
|
|
echo "Release ${TAG} created with packages attached"
|
|
shell: bash
|