mirror of
https://github.com/openwrt-xiaomi/builder.git
synced 2026-02-02 23:47:48 +05:00
Compare commits
9 Commits
ef5e7155b5
...
e021297496
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e021297496 | ||
|
|
0cb316891c | ||
|
|
aed5f171a8 | ||
|
|
08cccf41b7 | ||
|
|
e6e97ddbc8 | ||
|
|
b650894e8a | ||
|
|
78cc0dee60 | ||
|
|
0b066fe854 | ||
|
|
67e187b849 |
204
.github/workflows/build.yml
vendored
204
.github/workflows/build.yml
vendored
@@ -3,6 +3,14 @@ name: build
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
first_kernel_compile:
|
||||
description: 'First kernel compile'
|
||||
required: true
|
||||
default: 'true'
|
||||
type: choice
|
||||
options:
|
||||
- true
|
||||
- false
|
||||
test_build:
|
||||
description: 'Test build'
|
||||
required: true
|
||||
@@ -36,6 +44,7 @@ on:
|
||||
type: string
|
||||
|
||||
env:
|
||||
FIRST_KERNEL_COMPILE: ${{ github.event.inputs.first_kernel_compile == 'true' }}
|
||||
TEST_BUILD: ${{ github.event.inputs.test_build == 'true' }}
|
||||
FAKE_BUILD: ${{ github.event.inputs.fake_build == 'true' }}
|
||||
TAG_SUFFIX: ${{ github.event.inputs.fake_build == 'true' && '-fake' || github.event.inputs.test_build == 'true' && '-test' || '' }}
|
||||
@@ -45,7 +54,6 @@ env:
|
||||
REPO_LNK: openwrt-xiaomi/openwrt
|
||||
REPO_BRANCH: xq-25.12
|
||||
TAG_PREFIX: v25-
|
||||
BUILD_ROOT: ${{ github.workspace }}/openwrt
|
||||
DEPENDENCIES: ${{ github.workspace }}/dependencies-ubuntu.txt
|
||||
TZ: UTC
|
||||
DEVICE_NAME: unknown
|
||||
@@ -183,22 +191,31 @@ jobs:
|
||||
uses: actions/checkout@main
|
||||
|
||||
- name: Download OpenWrt sources
|
||||
run: git clone --branch $REPO_BRANCH $REPO_URL.git $BUILD_ROOT
|
||||
run: |
|
||||
git clone --branch $REPO_BRANCH $REPO_URL.git openwrt
|
||||
rm -rf .git
|
||||
rsync -a openwrt/ ./
|
||||
rm -rf openwrt
|
||||
|
||||
- name: Init builder
|
||||
env:
|
||||
BLDROOT: ${{ github.workspace }}
|
||||
shell: bash
|
||||
run: |
|
||||
rsync -avq --exclude=".*" --exclude="$(basename $BUILD_ROOT)" $BLDROOT/ $BUILD_ROOT/
|
||||
cd $BUILD_ROOT
|
||||
chmod +x *.sh
|
||||
wget https://github.com/fantastic-packages/packages/raw/refs/heads/25.12/keys/usign/53FF2B6672243D28.pub
|
||||
|
||||
- name: Cache downloads (dl)
|
||||
if: false
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: dl
|
||||
key: dl-${{ hashFiles('feeds.conf.default') }}
|
||||
restore-keys: |
|
||||
dl-
|
||||
|
||||
- name: Update OpenWrt packages
|
||||
id: update
|
||||
run: |
|
||||
cd $BUILD_ROOT && ./xupdate.sh -f
|
||||
./xupdate.sh -f
|
||||
mkdir -p logs
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Configure
|
||||
@@ -208,8 +225,6 @@ jobs:
|
||||
TARGET: ${{ matrix.target }}
|
||||
FW_VER: ${{ needs.check.outputs.fw_ver }}
|
||||
run: |
|
||||
cd $BUILD_ROOT && echo "init build config"
|
||||
FILE_DATE=$(date --utc +'%y%m%d')
|
||||
./xmake.sh -I -t $TARGET
|
||||
G_DEVICE_NAME=$( grep -so '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' )
|
||||
[ -z "$G_DEVICE_NAME" ] && exit 31
|
||||
@@ -217,6 +232,8 @@ jobs:
|
||||
[ -z "$G_BOARD_NAME" ] && exit 32
|
||||
G_SUBTARGET_NAME=$( grep -so '^CONFIG_TARGET_SUBTARGET=.*' .config | cut -d'"' -f2 )
|
||||
[ -z "$G_SUBTARGET_NAME" ] && exit 33
|
||||
G_TARGET_ARCH=$( grep -so '^CONFIG_TARGET_ARCH_PACKAGES=.*' .config | cut -d'"' -f2 )
|
||||
echo "G_TARGET_ARCH = $G_TARGET_ARCH"
|
||||
VERMAGIC_LIST="vermagic-$G_BOARD_NAME-$G_SUBTARGET_NAME-*.list"
|
||||
if [ $(find . -maxdepth 1 -name "$VERMAGIC_LIST" | wc -l) = "0" ]; then
|
||||
./vermagic_update.sh $G_BOARD_NAME $G_SUBTARGET_NAME
|
||||
@@ -224,102 +241,69 @@ jobs:
|
||||
if [ $(find . -maxdepth 1 -name "$VERMAGIC_LIST" | wc -l) = "0" ]; then
|
||||
exit 41
|
||||
fi
|
||||
FILE_DATE=$(date --utc +'%y%m%d')
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
echo "FW_VER=$FW_VER" >> $GITHUB_ENV
|
||||
echo "G_DEVICE_NAME=$G_DEVICE_NAME" >> $GITHUB_ENV
|
||||
echo "G_BOARD_NAME=$G_BOARD_NAME" >> $GITHUB_ENV
|
||||
echo "G_SUBTARGET_NAME=$G_SUBTARGET_NAME" >> $GITHUB_ENV
|
||||
echo "G_TARGET_ARCH=$G_TARGET_ARCH" >> $GITHUB_ENV
|
||||
echo "FILE_DATE=$FILE_DATE" >> $GITHUB_ENV
|
||||
|
||||
- name: Dump .config file
|
||||
run: |
|
||||
echo "====== .config ========="
|
||||
cat $BUILD_ROOT/.config
|
||||
cat .config
|
||||
echo "========================"
|
||||
|
||||
- name: Download tools and toolchain
|
||||
id: tools_download
|
||||
if: false # steps.configure.outputs.status == 'success'
|
||||
- name: Prepare for use cache of tools and toolchain
|
||||
run: |
|
||||
cd $BUILD_ROOT
|
||||
G_TARGET_ARCH=$( grep -so '^CONFIG_TARGET_ARCH_PACKAGES=' .config | cut -d'"' -f2 )
|
||||
echo "G_TARGET_ARCH=$G_TARGET_ARCH" >> $GITHUB_ENV
|
||||
echo "OpenWrt version: $FW_VER"
|
||||
SDK_URL_BASE="https://downloads.openwrt.org/releases/${FW_VER}/targets/${G_BOARD_NAME}/${G_SUBTARGET_NAME}"
|
||||
echo "Searching SDK at $SDK_URL_BASE"
|
||||
SDK_TARBALL=$( curl -s "$SDK_URL_BASE/" | grep -oE 'openwrt-sdk-[^"]+Linux-x86_64\.tar\.(xz|zst)' | head -n1 )
|
||||
if [ -z "$SDK_TARBALL" ]; then
|
||||
echo "ERROR: SDK not found for ${G_BOARD_NAME}/${G_SUBTARGET_NAME}"
|
||||
exit 81
|
||||
fi
|
||||
echo "Found SDK: $SDK_TARBALL"
|
||||
#curl -L --fail --retry 5 --retry-delay 5 --progress-bar -o "$SDK_TARBALL" "$SDK_URL_BASE/$SDK_TARBALL"
|
||||
wget --progress=dot:mega "$SDK_URL_BASE/$SDK_TARBALL"
|
||||
if [[ "$SDK_TARBALL" == *.tar.xz ]]; then
|
||||
tar -xf "$SDK_TARBALL"
|
||||
elif [[ "$SDK_TARBALL" == *.tar.zst ]]; then
|
||||
tar -I zstd -xf "$SDK_TARBALL"
|
||||
else
|
||||
echo "Unknown archive format: $SDK_TARBALL"
|
||||
exit 82
|
||||
fi
|
||||
SDK_DIR=$(tar -tf "$SDK_TARBALL" | head -n1 | cut -d/ -f1)
|
||||
echo "Using SDK dir: $SDK_DIR"
|
||||
rm -rf staging_dir
|
||||
mv "$SDK_DIR/staging_dir" .
|
||||
echo "========= staging_dir =========="
|
||||
ls -l staging_dir
|
||||
echo "================================"
|
||||
#cp -a "$SDK_DIR"/toolchain/* toolchain/ 2>/dev/null || true
|
||||
TOOLS_DIR=staging_dir/host
|
||||
touch $TOOLS_DIR/.prepared
|
||||
TOOLS_STAMP_DIR=$TOOLS_DIR/stamp
|
||||
TOOLS_PKGS=$(
|
||||
find tools/ -maxdepth 1 -mindepth 1 -type d | while read -r d; do
|
||||
mk="$d/Makefile"
|
||||
[ -f "$mk" ] || continue
|
||||
awk -F':=' '
|
||||
/^[[:space:]]*PKG_NAME[[:space:]]*:=/ {
|
||||
v=$2
|
||||
gsub(/\r/, "", v)
|
||||
gsub(/^[[:space:]]+/, "", v)
|
||||
gsub(/[[:space:]]+$/, "", v)
|
||||
if (v != "") print v
|
||||
}
|
||||
' "$mk"
|
||||
done | sort -u
|
||||
)
|
||||
mkdir -p "$TOOLS_STAMP_DIR"
|
||||
echo "Found host tools packages: $TOOLS_PKGS"
|
||||
for pkg in $TOOLS_PKGS; do
|
||||
touch "$TOOLS_STAMP_DIR/.$pkg"_installed
|
||||
done
|
||||
TOOLCHAIN_DIR=$( find staging_dir -maxdepth 1 -type d -name "toolchain-*" )
|
||||
echo "Found toolchain directory: $TOOLCHAIN_DIR"
|
||||
#touch $TOOLCHAIN_DIR/.prepared
|
||||
mkdir -p "$TOOLCHAIN_DIR/stamp"
|
||||
touch $TOOLCHAIN_DIR/stamp/.binutils_installed
|
||||
#touch $TOOLCHAIN_DIR/stamp/.fortify-headers_installed
|
||||
touch $TOOLCHAIN_DIR/stamp/.gcc_final_installed
|
||||
touch $TOOLCHAIN_DIR/stamp/.gcc_initial_installed
|
||||
touch $TOOLCHAIN_DIR/stamp/.gdb_installed
|
||||
#touch $TOOLCHAIN_DIR/stamp/.linux_installed
|
||||
touch $TOOLCHAIN_DIR/stamp/.musl_installed
|
||||
touch $TOOLCHAIN_DIR/stamp/.toolchain_compile
|
||||
echo "Checking cross-compiler..."
|
||||
find staging_dir -name '*gcc' | head -n 10
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
echo "G_TARGET_ARCH = $G_TARGET_ARCH"
|
||||
rm -rf staging_dir/
|
||||
rm -rf build_dir/
|
||||
|
||||
- name: Cache host tools
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: staging_dir/host
|
||||
key: host-tools-${{ runner.os }}-${{ hashFiles('tools/**') }}
|
||||
restore-keys: |
|
||||
host-tools-${{ runner.os }}-
|
||||
|
||||
- name: Cache toolchain
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: staging_dir/toolchain-*
|
||||
key: toolchain-${{ env.G_TARGET_ARCH }}-${{ hashFiles('toolchain/**') }}
|
||||
restore-keys: |
|
||||
toolchain-${{ env.G_TARGET_ARCH }}-
|
||||
|
||||
- name: Build tools and toolchain
|
||||
id: tools
|
||||
if: steps.configure.outputs.status == 'success'
|
||||
if: ${{ steps.configure.outputs.status == 'success' && github.event.inputs.fake_build != 'true' }}
|
||||
run: |
|
||||
cd $BUILD_ROOT
|
||||
MAKE_JOBS=$(nproc)
|
||||
echo "$MAKE_JOBS thread compile"
|
||||
export CCACHE=1
|
||||
make tools/install -j$MAKE_JOBS
|
||||
make toolchain/install -j$MAKE_JOBS
|
||||
make toolchain/install -j$(nproc)
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Save cache for host tools
|
||||
if: ${{ steps.tools.outputs.status == 'success' && github.event.inputs.fake_build != 'true' }}
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: staging_dir/host
|
||||
key: host-tools-${{ runner.os }}-${{ hashFiles('tools/**') }}
|
||||
|
||||
- name: Save cache for toolchain
|
||||
if: ${{ steps.tools.outputs.status == 'success' && github.event.inputs.fake_build != 'true' }}
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: staging_dir/toolchain-*
|
||||
key: toolchain-${{ env.G_TARGET_ARCH }}-${{ hashFiles('toolchain/**') }}
|
||||
|
||||
- name: Kernel compile
|
||||
id: kernel
|
||||
if: ${{ steps.tools.outputs.status == 'success' && github.event.inputs.first_kernel_compile == 'true' && github.event.inputs.fake_build != 'true' }}
|
||||
run: |
|
||||
make target/linux/compile -j$(nproc)
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build the firmware image
|
||||
@@ -328,29 +312,25 @@ jobs:
|
||||
env:
|
||||
TARGET: ${{ matrix.target }}
|
||||
run: |
|
||||
cd $BUILD_ROOT
|
||||
MAKE_JOBS=$(nproc)
|
||||
echo "$MAKE_JOBS thread compile"
|
||||
export CCACHE=1
|
||||
echo "Run $(nproc) thread compile"
|
||||
if [ "$FAKE_BUILD" != "true" -a "$TEST_BUILD" = "true" -a "$PACKAGE_DIR" != "" ]; then
|
||||
make $PACKAGE_DIR/compile V=sc BUILD_LOG=1
|
||||
exit 99
|
||||
fi
|
||||
if [ "$FAKE_BUILD" != "true" ]; then
|
||||
if [ "$TEST_BUILD" != "true" ]; then
|
||||
make -j $MAKE_JOBS download world
|
||||
make -j$(nproc) download world
|
||||
else
|
||||
make V=sc download world
|
||||
fi
|
||||
fi
|
||||
# process results
|
||||
OUT_DIR=$BUILD_ROOT/bin/targets/$G_BOARD_NAME/$G_SUBTARGET_NAME
|
||||
OUT_DIR=bin/targets/$G_BOARD_NAME/$G_SUBTARGET_NAME
|
||||
if [ "$FAKE_BUILD" = "true" ]; then
|
||||
mkdir -p logs
|
||||
mkdir -p $OUT_DIR
|
||||
echo "$G_BOARD_NAME $G_SUBTARGET_NAME $G_DEVICE_NAME" > "$OUT_DIR/$G_DEVICE_NAME.txt"
|
||||
touch "$OUT_DIR/kernel-debug.tar.zst"
|
||||
ls -la
|
||||
BLD_VER=$FW_VER
|
||||
else
|
||||
BLD_VER=$( cat $OUT_DIR/profiles.json | grep -so '"version_number":"[^"]*' | grep -so '[^"]*$' )
|
||||
@@ -361,12 +341,23 @@ jobs:
|
||||
exit 100
|
||||
fi
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
echo "DEVICE_NAME=$G_DEVICE_NAME" >> $GITHUB_ENV
|
||||
echo "BOARD_NAME=$G_BOARD_NAME" >> $GITHUB_ENV
|
||||
echo "SUBTARGET_NAME=$G_SUBTARGET_NAME" >> $GITHUB_ENV
|
||||
echo "FW_BUILD_OK=1" >> $GITHUB_ENV
|
||||
echo "BLD_VER=$BLD_VER" >> $GITHUB_ENV
|
||||
echo "OUT_DIR=$OUT_DIR" >> $GITHUB_ENV
|
||||
|
||||
- name: Mark firmware build failed
|
||||
if: false # steps.compile.outcome == 'failure'
|
||||
run: |
|
||||
echo "Firmware build failed, continuing pipeline"
|
||||
echo "FW_BUILD_OK=0" >> $GITHUB_ENV
|
||||
OUT_DIR=_bin_fake
|
||||
mkdir -p $OUT_DIR
|
||||
echo "$G_BOARD_NAME $G_SUBTARGET_NAME $G_DEVICE_NAME" > "$OUT_DIR/$G_DEVICE_NAME.txt"
|
||||
touch "$OUT_DIR/kernel-debug.tar.zst"
|
||||
echo "BUILD FAILED" > $OUT_DIR/FAILED.txt
|
||||
echo "BLD_VER=$FW_VER" >> $GITHUB_ENV
|
||||
echo "OUT_DIR=$OUT_DIR" >> $GITHUB_ENV
|
||||
|
||||
- name: Check space usage
|
||||
run: df -hT
|
||||
|
||||
@@ -375,9 +366,8 @@ jobs:
|
||||
env:
|
||||
TARGET: ${{ matrix.target }}
|
||||
FW_DATE: ${{ needs.check.outputs.fw_date }}
|
||||
LOGS_DIR: ${{ env.BUILD_ROOT }}/logs
|
||||
run: |
|
||||
tar -cJvf logs-$TARGET-$FW_DATE.tar.xz $LOGS_DIR
|
||||
tar -cJvf logs-$TARGET-$FW_DATE.tar.xz logs
|
||||
|
||||
- name: Cleanup OUT directory
|
||||
if: steps.compile.outputs.status == 'success'
|
||||
@@ -402,7 +392,7 @@ jobs:
|
||||
uses: actions/upload-artifact@main
|
||||
if: steps.compile.outputs.status == 'success'
|
||||
with:
|
||||
name: openwrt-${{ env.BLD_VER }}-${{ needs.check.outputs.build_date }}-${{ env.DEVICE_NAME }}
|
||||
name: openwrt-${{ env.BLD_VER }}-${{ needs.check.outputs.build_date }}-${{ env.G_DEVICE_NAME }}
|
||||
path: ${{ env.OUT_DIR }}
|
||||
if-no-files-found: error
|
||||
|
||||
@@ -426,6 +416,16 @@ jobs:
|
||||
with:
|
||||
pattern: openwrt-*
|
||||
|
||||
- name: Check for failed builds
|
||||
run: |
|
||||
echo "Checking for FAILED.txt in openwrt-* directories..."
|
||||
FAILED_DIRS=$( find . -maxdepth 1 -type d -name 'openwrt-*' -exec test -f '{}/FAILED.txt' \; -print )
|
||||
if [ -n "$FAILED_DIRS" ]; then
|
||||
echo "❌ Build failures detected in:"
|
||||
exit 201
|
||||
fi
|
||||
echo "✅ No FAILED.txt found, proceeding to release"
|
||||
|
||||
- name: Put images into zip
|
||||
run: |
|
||||
mkdir -p public
|
||||
|
||||
Reference in New Issue
Block a user