Some checks failed
Build & Package / build (push) Failing after 8m30s
- Add actions/upload-artifact to make .deb/.rpm downloadable from each build run in the Gitea UI - On tagged builds (v*), create a Gitea release with packages attached via the API - Install nodejs for the upload-artifact action Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
138 lines
4.4 KiB
YAML
138 lines
4.4 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-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: |
|
|
. "$HOME/.cargo/env"
|
|
# build.rs auto-compiles the eBPF program via aya-build
|
|
cargo build --release -p tcptop
|
|
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
|
|
shell: bash
|
|
|
|
- name: Build .rpm package
|
|
run: |
|
|
. "$HOME/.cargo/env"
|
|
cargo generate-rpm -p tcptop
|
|
shell: bash
|
|
|
|
- name: Collect packages
|
|
run: |
|
|
mkdir -p dist
|
|
cp target/debian/tcptop_*.deb dist/
|
|
cp target/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')
|
|
run: |
|
|
TAG="${GITHUB_REF_NAME}"
|
|
# Create release via Gitea API
|
|
RELEASE_ID=$(curl -s -X POST \
|
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${TAG}\", \"body\": \"tcptop ${TAG}\"}" \
|
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases" \
|
|
| grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
|
# Attach packages to the release
|
|
for f in dist/*; do
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
-F "attachment=@${f}" \
|
|
"${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets"
|
|
done
|
|
echo "Release ${TAG} created with packages attached"
|
|
shell: bash
|