mirror of
https://github.com/openwrt-xiaomi/builder.git
synced 2026-01-01 19:43:41 +05:00
build: Sync code with v25 branch
This commit is contained in:
207
.github/workflows/build.yml
vendored
207
.github/workflows/build.yml
vendored
@@ -3,6 +3,32 @@ 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
|
||||
default: 'false'
|
||||
type: choice
|
||||
options:
|
||||
- true
|
||||
- false
|
||||
target_name:
|
||||
description: 'Target Name'
|
||||
required: false
|
||||
default: 'r3d'
|
||||
type: string
|
||||
package_dir:
|
||||
description: 'Package Dir'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
fake_build:
|
||||
description: 'Fake build'
|
||||
required: true
|
||||
@@ -18,12 +44,16 @@ on:
|
||||
type: string
|
||||
|
||||
env:
|
||||
FAKE_BUILD: ${{ github.event.inputs.fake_build }}
|
||||
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' || '' }}
|
||||
TARGET_NAME: ${{ github.event.inputs.target_name }}
|
||||
PACKAGE_DIR: ${{ github.event.inputs.package_dir }}
|
||||
REPO_URL: https://github.com/openwrt-xiaomi/openwrt
|
||||
REPO_LNK: openwrt-xiaomi/openwrt
|
||||
REPO_BRANCH: xq-24.10
|
||||
TAG_PREFIX: v24-
|
||||
BUILD_ROOT: ${{ github.workspace }}/openwrt
|
||||
DEPENDENCIES: ${{ github.workspace }}/dependencies-ubuntu.txt
|
||||
TZ: UTC
|
||||
DEVICE_NAME: unknown
|
||||
@@ -45,6 +75,9 @@ jobs:
|
||||
fw_date: ${{ steps.gh.outputs.fw_date }}
|
||||
fw_ver: ${{ steps.gh.outputs.fw_ver }}
|
||||
is_active: ${{ steps.activity.outputs.is_active }}
|
||||
test_build: ${{ env.TEST_BUILD }}
|
||||
target_name: ${{ env.TARGET_NAME }}
|
||||
fake_build: ${{ env.FAKE_BUILD }}
|
||||
steps:
|
||||
- name: Get repo data via GH API
|
||||
id: gh
|
||||
@@ -124,6 +157,12 @@ jobs:
|
||||
- tuf_ax4200
|
||||
- tuf_ax6000
|
||||
- zen-bt8
|
||||
isTest:
|
||||
- ${{ needs.check.outputs.test_build == 'true' }}
|
||||
exclude:
|
||||
- { isTest: true }
|
||||
include:
|
||||
- target: ${{ github.event.inputs.target_name }}
|
||||
steps:
|
||||
- name: Initialization environment
|
||||
env:
|
||||
@@ -131,7 +170,10 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get -qq update
|
||||
#sudo apt-get -qq update && sudo apt-get -qq upgrade
|
||||
sudo apt-get -qq install $(cat $DEPENDENCIES)
|
||||
sudo apt-get -qq install build-essential gawk flex rsync swig unzip zlib1g-dev file wget
|
||||
sudo apt-get -qq install libc6-dev clang flex bison g++ gcc-multilib g++-multilib
|
||||
sudo apt-get -qq install gettext git libncurses5-dev libssl-dev python3-setuptools
|
||||
sudo apt-get -qq install libc6-dev pkg-config
|
||||
sudo apt-get -qq autoremove --purge
|
||||
sudo apt-get -qq clean
|
||||
sudo timedatectl set-timezone "$TZ"
|
||||
@@ -149,35 +191,40 @@ 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/24.10/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: Build the firmware image
|
||||
id: compile
|
||||
- name: Configure
|
||||
id: configure
|
||||
if: steps.update.outputs.status == 'success'
|
||||
env:
|
||||
TARGET: ${{ matrix.target }}
|
||||
FW_VER: ${{ needs.check.outputs.fw_ver }}
|
||||
run: |
|
||||
cd $BUILD_ROOT
|
||||
MAKE_JOBS=$(($(nproc)+1))
|
||||
echo "$MAKE_JOBS thread compile"
|
||||
# init build config
|
||||
./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
|
||||
@@ -185,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
|
||||
@@ -192,17 +241,96 @@ jobs:
|
||||
if [ $(find . -maxdepth 1 -name "$VERMAGIC_LIST" | wc -l) = "0" ]; then
|
||||
exit 41
|
||||
fi
|
||||
# run build
|
||||
[ "$FAKE_BUILD" != "true" ] && make -j $MAKE_JOBS download world
|
||||
# process results
|
||||
FILE_DATE=$(date --utc +'%y%m%d')
|
||||
OUT_DIR=$BUILD_ROOT/bin/targets/$G_BOARD_NAME/$G_SUBTARGET_NAME
|
||||
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 .config
|
||||
echo "========================"
|
||||
|
||||
- name: Prepare for use cache of tools and toolchain
|
||||
run: |
|
||||
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' && github.event.inputs.fake_build != 'true' }}
|
||||
run: |
|
||||
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
|
||||
id: compile
|
||||
if: steps.tools.outputs.status == 'success'
|
||||
env:
|
||||
TARGET: ${{ matrix.target }}
|
||||
run: |
|
||||
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$(nproc) download world
|
||||
else
|
||||
make V=sc download world
|
||||
fi
|
||||
fi
|
||||
# process results
|
||||
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 '[^"]*$' )
|
||||
@@ -213,12 +341,22 @@ 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
|
||||
echo "FILE_DATE=$FILE_DATE" >> $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
|
||||
@@ -228,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'
|
||||
@@ -255,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
|
||||
|
||||
@@ -279,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
|
||||
@@ -291,8 +438,8 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
TAG: ${{ needs.check.outputs.tag }}
|
||||
with:
|
||||
prerelease: false
|
||||
tag_name: ${{ needs.check.outputs.tag }}
|
||||
prerelease: ${{ env.TEST_BUILD == 'true' || env.FAKE_BUILD == 'true' }}
|
||||
tag_name: ${{ needs.check.outputs.tag }}${{ env.TAG_SUFFIX }}
|
||||
name: '${{ needs.check.outputs.tag }}'
|
||||
body: |
|
||||
OpenWrt ${{ needs.check.outputs.fw_ver }} [${{ needs.check.outputs.fw_date }}]
|
||||
|
||||
Reference in New Issue
Block a user