mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-14 04:07:56 +08:00
update 2026-10-19 17:31:01
This commit is contained in:
1 parent
6604b3420d
commit
313fe55d56
38 files changed
+982
-1508
No files matched your search
+246
@@ -0,0 +1,246 @@
|
||||
name: Build packages
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
openwrt_majors:
|
||||
description: 'OpenWrt major versions (space-separated, e.g. 24 25)'
|
||||
required: false
|
||||
default: '24 25'
|
||||
type: string
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
actions: write
|
||||
|
||||
env:
|
||||
OPENWRT_MAJORS: '24 25'
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: Prepare version and matrix
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
release_tag: ${{ steps.meta.outputs.release_tag }}
|
||||
release_name: ${{ steps.meta.outputs.release_name }}
|
||||
sdks: ${{ steps.matrix.outputs.sdks }}
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Generate version metadata
|
||||
id: meta
|
||||
shell: bash
|
||||
run: |
|
||||
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)
|
||||
|
||||
release_tag="vmlinux-btf_r${pkg_release}_${date_tag}_${short_sha}"
|
||||
release_name="vmlinux-btf r${pkg_release} (${date_tag})"
|
||||
|
||||
echo "release_tag=${release_tag}" >> "$GITHUB_OUTPUT"
|
||||
echo "release_name=${release_name}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
echo "Release tag: ${release_tag}"
|
||||
echo "Release name: ${release_name}"
|
||||
|
||||
- name: Resolve latest SDK releases
|
||||
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"
|
||||
|
||||
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 || apt-get install -y dwarves || 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
|
||||
|
||||
# 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 | grep -E '\.(ipk|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 "*.ipk" -o -name "*.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
|
||||
Reference in new issue
Block a user