Skip to content

Build Armbian All Borad #7

Build Armbian All Borad

Build Armbian All Borad #7

name: Build Armbian All Borad
on:
workflow_dispatch:
inputs:
BOARD:
description: 'Board type'
required: true
default: 'all'
type: choice
options:
- all
- fine3399
- r08
- rock960
- sg2710
- tpm312
- tb-ls3399
- xiaobao-nas
- zysj
BRANCH:
description: 'Armbian branch'
default: 'current'
required: false
type: choice
options:
- legacy
- vendor
- current
- edge
RELEASE:
description: 'Release name'
default: 'bookworm'
required: true
type: choice
options:
- jammy
- bookworm
- noble
- bullseye
Version:
description: 'Armbian Version'
default: 'v24.08'
required: false
type: choice
options:
- main
- v24.08
BUILD_DESKTOP:
description: 'Build desktop environment'
default: 'no'
required: false
type: choice
options:
- no
COMPRESS_OUTPUTIMAGE:
description: 'Compress output image'
default: 'sha,xz'
required: false
type: string
BOOT_LOGO:
description: 'Include boot logo'
default: 'yes'
required: false
type: choice
options:
- yes
- no
env:
TZ: America/New_York
jobs:
build-armbian:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Initialization environment
id: init
env:
DEBIAN_FRONTEND: noninteractive
run: |
# 清理 Docker 镜像和软件缓存
docker_images_ids=$(docker images -q)
if [ -n "$docker_images_ids" ]; then
docker rmi $docker_images_ids
fi
docker image prune -a -f
sudo -E apt-get -y purge azure-cli ghc* zulu* llvm* firefox google* dotnet* openjdk* mysql* php* mongodb* dotnet* moby* snapd* android* || true
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
# 设置时区并创建工作目录
sudo timedatectl set-timezone "${TZ}"
sudo mkdir -p /mnt/workdir
sudo chown $USER:$GROUPS /mnt/workdir
df -Th
- name: Download source code
working-directory: /mnt/workdir
run: |
df -hT ${PWD}
git clone -q --single-branch --depth=1 --branch=${{ github.event.inputs.Version }} https://github.com/armbian/build.git build
ln -sf /mnt/workdir/build $GITHUB_WORKSPACE/build
cd build/
# 复制 config 和 userpatches 目录文件
cp -rf ${{ github.workspace }}/addboard/config/* config
mkdir -p userpatches
cp -rf ${{ github.workspace }}/addboard/userpatches/* userpatches
ls -la
- name: Compile Armbian [ ${{ inputs.BOARD }} ${{ inputs.RELEASE }} ]
run: |
cd build/
# 当 BOARD 为 all 时,遍历所有板类型
if [ "${{ inputs.BOARD }}" = "all" ]; then
declare -a BOARDS=("fine3399" "r08" "rock960" "sg2710" "tpm312" "tb-ls3399" "xiaobao-nas" "zysj")
for BOARD in "${BOARDS[@]}"; do
echo "Compiling for board: $BOARD"
./compile.sh BOARD=$BOARD RELEASE=${{ inputs.RELEASE }} BRANCH=${{ inputs.BRANCH }} BUILD_MINIMAL=no BUILD_DESKTOP=${{ inputs.BUILD_DESKTOP }} \
KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=${{ inputs.COMPRESS_OUTPUTIMAGE }} BOOT_LOGO=${{ inputs.BOOT_LOGO }}
if [ $? -ne 0 ]; then
echo "Compilation failed for board: $BOARD" >&2 # 将错误消息输出到标准错误流
fi
done
else
# 否则,仅对指定的 BOARD 进行编译
./compile.sh BOARD=$INPUT_BOARD RELEASE=${{ inputs.RELEASE }} BRANCH=${{ inputs.BRANCH }} BUILD_MINIMAL=no BUILD_DESKTOP=${{ inputs.BUILD_DESKTOP }} \
KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=${{ inputs.COMPRESS_OUTPUTIMAGE }} BOOT_LOGO=${{ inputs.BOOT_LOGO }}
if [ $? -ne 0 ]; then
echo "Compilation failed for specified board: $INPUT_BOARD" >&2
exit 1 # 如果是指定单个板子且失败,则退出脚本
fi
fi
- name: Set current year and month
run: |
echo "CURRENT_YEAR_MONTH=$(date +'%Y%m')" >> $GITHUB_ENV
- name: Prepare Release Metadata
run: |
# 提取版本号
# latest_image=$(ls ${{ github.workspace }}/build/output/images/Armbian-unofficial_*.img.xz | grep -oE 'Armbian-unofficial_[0-9.]+_.*' | sort -V | tail -n 1)
latest_image=$(ls ${{ github.workspace }}/build/output/images/Armbian-unofficial_*.img.xz | sort -V | tail -n 1)
version=$(echo "$latest_image" | cut -d'_' -f2)
# 将版本号设置为环境变量
echo "VERSION=$version" >> $GITHUB_ENV
- name: Upload image to Release
if: success()
uses: ncipollo/release-action@main
with:
tag: "Armbian_${{ github.event.inputs.Version }}_${{ github.event.inputs.RELEASE }}_${{ env.CURRENT_YEAR_MONTH }}"
name: "Armbian_${{ github.event.inputs.Version }}_${{ github.event.inputs.RELEASE }}_${{ env.CURRENT_YEAR_MONTH }}"
artifacts: "${{ github.workspace }}/build/output/images/*"
allowUpdates: true
removeArtifacts: false
replacesArtifacts: true
token: ${{ secrets.MY_TOKEN }}
body: |
### Armbian Image Information
- Release: ${{ github.event.inputs.RELEASE }}
- Version: ${{ env.VERSION }}
### Armbian Image Verification
- sha256sum
draft: false
prerelease: false