Adapt CI and installer to self-hosted Gitea, cross-compile arm64

Retarget the build pipeline and installer from GitHub to the
git.chilldove.com Gitea instance (icePigeon/linux-kernel-bbrv3).

- build.yml: replace gh CLI release checks and softprops/action-gh-release
  with Gitea REST API calls (curl); drop the GitHub-only delete-workflow-runs
  cleanup job; authenticate via the auto-injected GITEA_TOKEN.
- Avoid actions/upload-artifact@v4 / download-artifact@v4 (they abort on
  Gitea as GHES): pass the config baseline between jobs via Gitea release
  assets instead of artifacts, and drop the redundant deb/marker artifacts.
- Cross-compile arm64 on the single x86_64 runner
  (CROSS_COMPILE=aarch64-linux-gnu-, gcc-aarch64-linux-gnu); thread
  CROSS_COMPILE through prepare-kernel-config.sh olddefconfig.
- install.sh: fetch releases from the Gitea API, self-update and CVE
  detector from Gitea raw URLs, token-authenticated asset downloads,
  paginate the release list; keep GITHUB_TOKEN/GH_TOKEN as fallbacks.
- README.md: point install/download URLs at Gitea, reword GitHub -> Gitea,
  remove the GitHub-only Star History widget.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-06-17 13:24:54 +08:00
parent b5a270b34a
commit 8ac6ae9411
4 changed files with 218 additions and 138 deletions
+151 -97
View File
@@ -1,5 +1,16 @@
name: 构建带有BBRv3的内核
# Gitea Actions reads workflows from .github/workflows/ (and .gitea/workflows/).
# This workflow targets a self-hosted Gitea instance:
# * release existence checks, creation and asset uploads go through the Gitea
# REST API (curl), not the GitHub `gh` CLI;
# * config-baseline data is passed between jobs via Gitea release assets, NOT via
# actions/upload-artifact@v4 — the upstream artifact v4 actions detect Gitea as
# GHES and abort, so they are avoided entirely;
# * arm64 kernels are cross-compiled on the x86_64 runner
# (CROSS_COMPILE=aarch64-linux-gnu-), so only a single ubuntu-latest runner is
# required.
on:
workflow_dispatch:
schedule:
@@ -7,13 +18,14 @@ on:
- cron: "17 3 * * *"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
# Gitea auto-injects GITHUB_TOKEN / GITEA_TOKEN into Actions jobs.
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Gitea REST API base for this repo, e.g.
# https://git.chilldove.com/api/v1/repos/icePigeon/linux-kernel-bbrv3
GITEA_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
permissions:
contents: write
actions: write
concurrency:
group: bbrv3-kernel-build
@@ -51,11 +63,20 @@ jobs:
echo "raw_kernel_version=$raw_version" >> "$GITHUB_OUTPUT"
echo "kernel_version=$version" >> "$GITHUB_OUTPUT"
# Returns 0 when a release with the given tag already exists on Gitea.
release_exists() {
local tag="$1" code
code=$(curl -sS -o /dev/null -w '%{http_code}' \
-H "Authorization: token $GITEA_TOKEN" \
"$GITEA_API/releases/tags/$tag" || echo 000)
[ "$code" = "200" ]
}
missing=0
for arch in x86_64 arm64; do
for suffix in "" "-max"; do
tag="$arch-$version$suffix"
if gh release view "$tag" >/dev/null 2>&1; then
if release_exists "$tag"; then
echo "$tag already exists."
else
echo "$tag is missing."
@@ -72,44 +93,38 @@ jobs:
echo "At least one release for $version is missing; build will continue."
fi
cleanup:
build:
needs: preflight
if: needs.preflight.outputs.build_needed == 'true'
runs-on: ubuntu-latest
steps:
- name: 删除旧的工作流运行记录
uses: Mattraks/delete-workflow-runs@main
with:
retain_days: 0
keep_minimum_runs: 0
build:
needs: [preflight, cleanup]
if: ${{ always() && needs.preflight.outputs.build_needed == 'true' && needs.cleanup.result == 'success' }}
strategy:
fail-fast: false
matrix:
include:
# All targets build on a single x86_64 runner; arm64 is cross-compiled.
- arch: x86_64
runs_on: ubuntu-latest
cross_compile: ""
profile: standard
profile_name: BBRv3
release_suffix: ""
localversion: -bbrv3
- arch: arm64
runs_on: ubuntu-24.04-arm
runs_on: ubuntu-latest
cross_compile: aarch64-linux-gnu-
profile: standard
profile_name: BBRv3
release_suffix: ""
localversion: -bbrv3
- arch: x86_64
runs_on: ubuntu-latest
cross_compile: ""
profile: max
profile_name: BBRv3 Max
release_suffix: -max
localversion: -bbrv3-max
- arch: arm64
runs_on: ubuntu-24.04-arm
runs_on: ubuntu-latest
cross_compile: aarch64-linux-gnu-
profile: max
profile_name: BBRv3 Max
release_suffix: -max
@@ -121,14 +136,19 @@ jobs:
steps:
- name: 检查是否已发布
id: check_release
env:
TAG: ${{ matrix.arch }}-${{ needs.preflight.outputs.kernel_version }}${{ matrix.release_suffix }}
PROFILE_NAME: ${{ matrix.profile_name }}
run: |
tag="${{ matrix.arch }}-${{ env.KERNEL_VERSION }}${{ matrix.release_suffix }}"
if gh release view "$tag" >/dev/null 2>&1; then
code=$(curl -sS -o /dev/null -w '%{http_code}' \
-H "Authorization: token $GITEA_TOKEN" \
"$GITEA_API/releases/tags/$TAG" || echo 000)
if [ "$code" = "200" ]; then
echo "BUILD_NEEDED=false" >> "$GITHUB_ENV"
echo "$tag already exists; skipping build."
echo "$TAG already exists; skipping build."
else
echo "BUILD_NEEDED=true" >> "$GITHUB_ENV"
echo "$tag does not exist; building latest kernel with ${{ matrix.profile_name }}."
echo "$TAG does not exist; building latest kernel with $PROFILE_NAME."
fi
- name: 检出代码
@@ -146,6 +166,11 @@ jobs:
dpkg-dev fakeroot kmod cpio dwarves \
libdw-dev lz4 zstd xz-utils curl jq
- name: 安装 ARM64 交叉编译工具链
if: env.BUILD_NEEDED == 'true' && matrix.arch == 'arm64'
run: |
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: 创建源码目录
if: env.BUILD_NEEDED == 'true'
run: mkdir -p ./kernel/linux
@@ -154,7 +179,7 @@ jobs:
if: env.BUILD_NEEDED == 'true'
working-directory: ./kernel
run: |
branch=$(echo "${{ env.KERNEL_VERSION }}" | grep -oP '^\d+\.\d+')
branch=$(echo "$KERNEL_VERSION" | grep -oP '^\d+\.\d+')
git clone --depth=1 --branch linux-$branch.y \
https://github.com/gregkh/linux.git linux
@@ -174,23 +199,25 @@ jobs:
- name: 编译声明
if: env.BUILD_NEEDED == 'true'
working-directory: ./kernel/linux
env:
PROFILE: ${{ matrix.profile }}
run: |
grep -v "MODULE_DESCRIPTION" net/ipv4/tcp_bbr.c > net/ipv4/tcp_bbr.c.tmp
mv net/ipv4/tcp_bbr.c.tmp net/ipv4/tcp_bbr.c
if [ "${{ matrix.profile }}" = "max" ]; then
if [ "$PROFILE" = "max" ]; then
echo 'MODULE_DESCRIPTION("TCP BBR v3 Max - aggressive throughput profile by Joey");' >> net/ipv4/tcp_bbr.c
else
echo 'MODULE_DESCRIPTION("TCP BBR v3 (Bottleneck Bandwidth and RTT) - Compiled & Optimized by Joey");' >> net/ipv4/tcp_bbr.c
fi
tail -n 5 net/ipv4/tcp_bbr.c
- name: 更新 Makefile 中的版本号
if: env.BUILD_NEEDED == 'true'
working-directory: ./kernel/linux
run: |
IFS='.' read -r v p s <<< "${{ env.KERNEL_VERSION }}"
IFS='.' read -r v p s <<< "$KERNEL_VERSION"
sed -i "s/^VERSION *=.*/VERSION = $v/" Makefile
sed -i "s/^PATCHLEVEL *=.*/PATCHLEVEL = $p/" Makefile
sed -i "s/^SUBLEVEL *=.*/SUBLEVEL = $s/" Makefile
@@ -199,24 +226,24 @@ jobs:
if: env.BUILD_NEEDED == 'true'
timeout-minutes: 8
working-directory: ./kernel/linux
env:
TARGET_ARCH: ${{ matrix.arch }}
CROSS_COMPILE: ${{ matrix.cross_compile }}
run: |
bash "$GITHUB_WORKSPACE/scripts/prepare-kernel-config.sh" "${{ matrix.arch }}"
- name: 上传最终配置文件
if: env.BUILD_NEEDED == 'true' && matrix.profile == 'standard'
uses: actions/upload-artifact@v4
with:
name: config-${{ matrix.arch }}-${{ matrix.profile }}-${{ env.KERNEL_VERSION }}
path: ./build-configs/${{ matrix.arch }}*.config
bash "$GITHUB_WORKSPACE/scripts/prepare-kernel-config.sh" "$TARGET_ARCH"
- name: 构建内核 Debian 包
if: env.BUILD_NEEDED == 'true'
working-directory: ./kernel/linux
env:
TARGET_ARCH: ${{ matrix.arch }}
LOCALVERSION_SUFFIX: ${{ matrix.localversion }}
CROSS_COMPILE: ${{ matrix.cross_compile }}
run: |
if [ "${{ matrix.arch }}" = "arm64" ]; then
make ARCH=arm64 bindeb-pkg -j$(nproc) LOCALVERSION=${{ matrix.localversion }} KDEB_COMPRESS=gzip skipdbg=true
if [ "$TARGET_ARCH" = "arm64" ]; then
make ARCH=arm64 CROSS_COMPILE="$CROSS_COMPILE" bindeb-pkg -j$(nproc) LOCALVERSION="$LOCALVERSION_SUFFIX" KDEB_COMPRESS=gzip skipdbg=true
else
make bindeb-pkg -j$(nproc) LOCALVERSION=${{ matrix.localversion }} KDEB_COMPRESS=gzip skipdbg=true
make bindeb-pkg -j$(nproc) LOCALVERSION="$LOCALVERSION_SUFFIX" KDEB_COMPRESS=gzip skipdbg=true
fi
- name: 检查 deb 包
@@ -231,93 +258,120 @@ jobs:
- name: 发布前复查是否已发布
if: env.BUILD_NEEDED == 'true'
env:
TAG: ${{ matrix.arch }}-${{ needs.preflight.outputs.kernel_version }}${{ matrix.release_suffix }}
run: |
tag="${{ matrix.arch }}-${KERNEL_VERSION}${{ matrix.release_suffix }}"
if gh release view "$tag" >/dev/null 2>&1; then
code=$(curl -sS -o /dev/null -w '%{http_code}' \
-H "Authorization: token $GITEA_TOKEN" \
"$GITEA_API/releases/tags/$TAG" || echo 000)
if [ "$code" = "200" ]; then
echo "PUBLISH_NEEDED=false" >> "$GITHUB_ENV"
echo "$tag was published while this job was running; skipping upload and release."
echo "$TAG was published while this job was running; skipping upload and release."
else
echo "PUBLISH_NEEDED=true" >> "$GITHUB_ENV"
mkdir -p ./publish-markers
touch "./publish-markers/${{ matrix.arch }}-${{ matrix.profile }}"
echo "$tag still missing; publishing this build."
echo "$TAG still missing; publishing this build."
fi
- name: 上传发布标记
- name: 发布到 Gitea Release
if: env.BUILD_NEEDED == 'true' && env.PUBLISH_NEEDED == 'true'
uses: actions/upload-artifact@v4
with:
name: publish-${{ matrix.arch }}-${{ matrix.profile }}-${{ env.KERNEL_VERSION }}
path: ./publish-markers/${{ matrix.arch }}-${{ matrix.profile }}
env:
TAG: ${{ matrix.arch }}-${{ needs.preflight.outputs.kernel_version }}${{ matrix.release_suffix }}
PROFILE_NAME: ${{ matrix.profile_name }}
TARGET_ARCH: ${{ matrix.arch }}
TARGET_SHA: ${{ github.sha }}
run: |
set -euo pipefail
body="带有 $PROFILE_NAME 的最新内核,适用于 $TARGET_ARCH 架构。Compiled & Optimized by Joey."
- name: 上传 deb 包
if: env.BUILD_NEEDED == 'true' && env.PUBLISH_NEEDED == 'true'
uses: actions/upload-artifact@v4
with:
name: deb-${{ matrix.arch }}-${{ matrix.profile }}
path: ./kernel/linux-*.deb
auth=(-H "Authorization: token $GITEA_TOKEN")
- name: 发布到 GitHub Release
if: env.BUILD_NEEDED == 'true' && env.PUBLISH_NEEDED == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ matrix.arch }}-${{ env.KERNEL_VERSION }}${{ matrix.release_suffix }}
files: |
./kernel/linux-*.deb
./build-configs/${{ matrix.arch }}-${{ env.KERNEL_VERSION }}.config
body: "带有 ${{ matrix.profile_name }} 的最新内核,适用于 ${{ matrix.arch }} 架构。Compiled & Optimized by Joey."
# Reuse an existing release for this tag, otherwise create it.
release_id=$(curl -sS "${auth[@]}" "$GITEA_API/releases/tags/$TAG" | jq -r '.id // empty')
if [ -z "$release_id" ]; then
release_id=$(curl -sS "${auth[@]}" \
-H "Content-Type: application/json" \
-X POST "$GITEA_API/releases" \
-d "$(jq -n \
--arg tag "$TAG" \
--arg target "$TARGET_SHA" \
--arg name "$TAG" \
--arg body "$body" \
'{tag_name:$tag, target_commitish:$target, name:$name, body:$body, draft:false, prerelease:false}')" \
| jq -r '.id // empty')
fi
if [ -z "$release_id" ] || [ "$release_id" = "null" ]; then
echo "Failed to resolve or create Gitea release for $TAG" >&2
exit 1
fi
# Collect assets: kernel debs plus the versioned arch config.
shopt -s nullglob
assets=( ./kernel/linux-*.deb )
cfg="./build-configs/$TARGET_ARCH-$KERNEL_VERSION.config"
[ -f "$cfg" ] && assets+=( "$cfg" )
if [ "${#assets[@]}" -eq 0 ]; then
echo "No assets found to upload for $TAG" >&2
exit 1
fi
for f in "${assets[@]}"; do
name=$(basename "$f")
echo "Uploading $name to release $TAG (id=$release_id)"
curl -fsS "${auth[@]}" \
-X POST "$GITEA_API/releases/$release_id/assets?name=$name" \
-F "attachment=@$f" >/dev/null
done
echo "Published $TAG with ${#assets[@]} asset(s)."
update-config-baseline:
needs: [preflight, build]
if: ${{ always() && needs.preflight.outputs.build_needed == 'true' && needs.build.result == 'success' }}
if: ${{ needs.preflight.outputs.build_needed == 'true' && needs.build.result == 'success' }}
runs-on: ubuntu-latest
env:
KERNEL_VERSION: ${{ needs.preflight.outputs.kernel_version }}
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 下载本轮最终配置
uses: actions/download-artifact@v4
continue-on-error: true
with:
pattern: config-*-standard-*
path: ./generated-configs
merge-multiple: true
- name: 下载发布标记
uses: actions/download-artifact@v4
continue-on-error: true
with:
pattern: publish-*-standard-*
path: ./publish-markers
merge-multiple: true
- name: 回写配置基线
run: |
set -euxo pipefail
if [ ! -d ./publish-markers ] || ! find ./publish-markers -type f | grep -q .; then
echo "No published architectures found; skipping baseline update."
exit 0
fi
auth=(-H "Authorization: token $GITEA_TOKEN")
if [ ! -f ./generated-configs/x86_64.config ] && [ ! -f ./generated-configs/arm64.config ]; then
echo "No generated configs found; nothing to update."
exit 0
fi
# Pull the generated .config for a freshly published standard release back
# into the repo baseline. Config travels as a Gitea release asset (named
# "<arch>-<version>.config"), so no actions/artifact is needed.
refresh_baseline() {
local arch="$1" baseline="$2"
local tag="$arch-$KERNEL_VERSION" # standard release (no -max)
local rel asset_name url
rel=$(curl -sS "${auth[@]}" "$GITEA_API/releases/tags/$tag")
if [ -z "$(echo "$rel" | jq -r '.id // empty')" ]; then
echo "Release $tag not found; skipping $baseline."
return 0
fi
asset_name="$arch-$KERNEL_VERSION.config"
url=$(echo "$rel" | jq -r --arg n "$asset_name" \
'.assets[]? | select(.name == $n) | .browser_download_url' | head -n1)
if [ -z "$url" ]; then
echo "Config asset $asset_name not found on $tag; skipping $baseline."
return 0
fi
curl -fsSL "${auth[@]}" -o "$baseline" "$url"
echo "Refreshed $baseline from $tag."
}
if [ -f ./publish-markers/x86_64-standard ] && [ -f ./generated-configs/x86_64.config ]; then
cp ./generated-configs/x86_64.config ./x86-64.config
fi
if [ -f ./publish-markers/arm64-standard ] && [ -f ./generated-configs/arm64.config ]; then
cp ./generated-configs/arm64.config ./arm64.config
fi
refresh_baseline x86_64 x86-64.config
refresh_baseline arm64 arm64.config
if git diff --quiet -- x86-64.config arm64.config; then
echo "Generated configs match current baselines."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "gitea-actions[bot]"
git config user.email "gitea-actions[bot]@noreply.git.chilldove.com"
git add x86-64.config arm64.config
git commit -m "Refresh generated kernel config baselines [skip ci]"
git push