update 2026-11-08 11:57:35

This commit is contained in:
action committed 2026-11-08 11:57:35 +08:00
1 parent d0f731bf67
commit 66c20961ac
4970 files changed
+2046310

No files matched your search

+255
View File
@@ -0,0 +1,255 @@
name: Build packages
on:
workflow_dispatch:
inputs:
openwrt_majors:
description: 'OpenWrt major versions (space-separated, e.g. 25)'
required: false
default: '25'
type: string
push:
branches:
- master
paths:
- 'Makefile'
- 'src/**'
permissions:
contents: write
actions: write
env:
OPENWRT_MAJORS: '25'
jobs:
prepare:
name: Prepare version and matrix
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.matrix.outputs.release_tag }}
release_name: ${{ steps.matrix.outputs.release_name }}
sdks: ${{ steps.matrix.outputs.sdks }}
steps:
- name: Checkout source
uses: actions/checkout@v6
- name: Resolve latest SDK releases and metadata
id: matrix
shell: bash
run: |
set -euo pipefail
raw_majors="${{ inputs.openwrt_majors }}"
majors=$(echo "${raw_majors:-$OPENWRT_MAJORS}" | tr ',' ' ')
echo "Target major versions: ${majors}"
tags=""
for i in {1..3}; do
tags=$(git ls-remote --tags --refs https://github.com/openwrt/openwrt.git 2>/dev/null | awk -F'/' '{print $NF}' | sed 's/^v//' || true)
[ -n "$tags" ] && break
sleep 2
done
if [ -z "$tags" ]; then
echo "::error::Failed to fetch tags from https://github.com/openwrt/openwrt.git"
exit 1
fi
sdks=()
for major in $majors; do
latest=$(echo "$tags" | grep -E "^${major}\.[0-9.]+$" | sort -V | tail -n 1 || true)
[ -z "$latest" ] && latest=$(echo "$tags" | grep -E "^${major}\." | sort -V | tail -n 1 || true)
if [ -n "$latest" ]; then
echo "OpenWrt ${major} -> ${latest}"
sdks+=("$latest")
else
echo "::error::No OpenWrt release tag found for major: ${major}"
exit 1
fi
done
echo "sdks=$(jq -nc --args '$ARGS.positional' -- "${sdks[@]}")" >> "$GITHUB_OUTPUT"
pkg_release=$(grep '^PKG_RELEASE:=' Makefile | head -n 1 | cut -d= -f2 | tr -d '[:space:]')
date_tag=$(date +'%Y%m%d')
short_sha=$(git rev-parse --short HEAD)
target_vers=$(IFS=, ; echo "${sdks[*]}")
target_vers_tag=$(IFS=_ ; echo "${sdks[*]}")
release_name="vmlinux-btf r${pkg_release} for OpenWrt ${target_vers} (${date_tag})"
release_tag="vmlinux-btf_r${pkg_release}_openwrt-${target_vers_tag}_${date_tag}_${short_sha}"
echo "release_name=${release_name}" >> "$GITHUB_OUTPUT"
echo "release_tag=${release_tag}" >> "$GITHUB_OUTPUT"
echo "Release name: ${release_name}"
echo "Release tag: ${release_tag}"
build:
name: Build ${{ matrix.arch }}-openwrt-${{ matrix.sdk }}
runs-on: ubuntu-latest
needs: prepare
strategy:
fail-fast: false
matrix:
arch:
- aarch64_generic
- aarch64_cortex-a53
- aarch64_cortex-a72
- aarch64_cortex-a76
- x86_64
sdk: ${{ fromJson(needs.prepare.outputs.sdks) }}
steps:
- name: Checkout source
uses: actions/checkout@v6
- name: Build packages with OpenWrt SDK
shell: bash
run: |
set -euo pipefail
mkdir -p artifacts feed/vmlinux-btf
cp -a Makefile src feed/vmlinux-btf/
[ ! -f README.md ] || cp -a README.md feed/vmlinux-btf/
image="docker.io/openwrt/sdk:${{ matrix.arch }}-${{ matrix.sdk }}"
echo "Pulling SDK image ${image}..."
docker pull "${image}"
docker run --rm \
--user root \
-v "${{ github.workspace }}/feed:/feed:ro" \
-v "${{ github.workspace }}/artifacts:/artifacts" \
"${image}" \
bash -c '
set -e
# Install host dwarves/pahole (Bullseye has dwarves; Bookworm/Alpine have dwarves/pahole)
if command -v apt-get >/dev/null 2>&1; then
if [ -f /etc/debian_version ] && grep -q '^11' /etc/debian_version; then
printf "deb [check-valid-until=no trusted=yes] http://archive.debian.org/debian/ bullseye main\ndeb [check-valid-until=no trusted=yes] http://archive.debian.org/debian-security/ bullseye-security main\n" > /etc/apt/sources.list
rm -rf /etc/apt/sources.list.d/*
fi
apt-get update -o Acquire::Check-Valid-Until=false || apt-get update
apt-get install -y --no-install-recommends dwarves llvm || apt-get install -y dwarves llvm || apt-get install -y pahole
rm -rf /var/lib/apt/lists/*
elif command -v apk >/dev/null 2>&1; then
apk add --no-cache dwarves
fi
# Verify pahole binary exists and is executable
pahole_bin="$(command -v pahole || which pahole || true)"
if [ -z "$pahole_bin" ] || [ ! -x "$pahole_bin" ]; then
echo "::error::pahole binary not found after package installation"
exit 1
fi
echo "Using pahole binary: $pahole_bin ($("$pahole_bin" --version))"
# Ensure pahole is accessible within OpenWrt staging_dir host tools
mkdir -p /builder/staging_dir/host/bin
ln -sf "$pahole_bin" /builder/staging_dir/host/bin/pahole
# Ensure real llvm-objcopy is accessible within OpenWrt staging_dir host tools
llvm_objcopy_bin="$(command -v llvm-objcopy || find /usr/bin -name 'llvm-objcopy*' 2>/dev/null | head -n 1 || true)"
if [ -n "$llvm_objcopy_bin" ]; then
ln -sf "$llvm_objcopy_bin" /builder/staging_dir/host/bin/llvm-objcopy
echo "Using llvm-objcopy: $llvm_objcopy_bin"
fi
# Fix permissions and compile as buildbot user
chown -R 1000:1000 /builder /artifacts
su -s /bin/bash buildbot -c '\''
set -e
[ ! -f setup.sh ] || bash setup.sh
echo "src-link packages_ci /feed" > feeds.conf
./scripts/feeds update packages_ci
./scripts/feeds install -p packages_ci vmlinux-btf
echo "CONFIG_PACKAGE_vmlinux-btf=m" >> .config
make defconfig
make package/vmlinux-btf/compile V=s
mkdir -p /artifacts/bin
cp -a bin/* /artifacts/bin/ 2>/dev/null || true
'\''
'
sudo chown -R "$USER:$USER" "${{ github.workspace }}/artifacts"
- name: Show built files
shell: bash
run: |
echo "=== Built package files ==="
find artifacts -type f \( -name "vmlinux-btf*.ipk" -o -name "vmlinux-btf*.apk" \) || true
echo "==========================="
- name: Prepare renamed artifacts
shell: bash
run: |
set -euo pipefail
mkdir -p dist
found=0
while IFS= read -r f; do
[ -n "$f" ] || continue
found=1
base="$(basename "$f")"
ext="${base##*.}"
name="${base%.*}"
if [[ "$name" == *"${{ matrix.arch }}"* ]] || [[ "$name" == *"all"* ]]; then
new_name="${name}-openwrt-${{ matrix.sdk }}.${ext}"
else
new_name="${name}-${{ matrix.arch }}-openwrt-${{ matrix.sdk }}.${ext}"
fi
cp "$f" "dist/${new_name}"
done < <(find artifacts -type f \( -name "vmlinux-btf*.ipk" -o -name "vmlinux-btf*.apk" \) 2>/dev/null)
if [ "$found" -eq 0 ]; then
echo "::error::No package files found in artifacts"
exit 1
fi
ls -lah dist
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.arch }}-openwrt-${{ matrix.sdk }}
path: dist/*
if-no-files-found: error
compression-level: 0
retention-days: 3
release:
name: Publish release
runs-on: ubuntu-latest
needs:
- prepare
- build
steps:
- name: Download all build artifacts
uses: actions/download-artifact@v8
with:
path: release-dist
merge-multiple: true
- name: Create or update GitHub release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ needs.prepare.outputs.release_tag }}
name: ${{ needs.prepare.outputs.release_name }}
files: release-dist/*
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Delete Old Releases
uses: ophub/delete-releases-workflows@main
with:
delete_releases: true
releases_keep_latest: 3
delete_tags: true
delete_workflows: true
workflows_keep_day: 3
gh_token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true