FunKey-OS Build All #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: FunKey-OS Build All | |
on: | |
workflow_dispatch: | |
env: | |
REPO_URL: https://github.com/286095742/FunBin-OS | |
UPLOAD_BIN_DIR: true | |
FIRMWARE_TAG: Funkey_OS_A33 | |
TZ: Asia/Shanghai | |
jobs: | |
Build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Check Server Performance(检查服务器性能) | |
run: | | |
echo "警告⚠" | |
echo "分配的服务器性能有限,若选择的插件过多,务必注意CPU性能!" | |
echo -e "已知CPU型号(降序):7763,8370C,8272CL,8171M,E5-2673 \n" | |
echo "--------------------------CPU信息--------------------------" | |
echo "CPU物理数量:$(cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l)" | |
echo -e "CPU核心信息:$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c) \n" | |
echo "--------------------------内存信息--------------------------" | |
echo "已安装内存详细信息:" | |
echo -e "$(sudo lshw -short -C memory | grep GiB) \n" | |
echo "--------------------------硬盘信息--------------------------" | |
echo "硬盘数量:$(ls /dev/sd* | grep -v [1-9] | wc -l)" && df -hT | |
- name: Initialization Environment(初始化环境) | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
docker rmi $(docker images -q) | |
sudo -E apt-get update | |
sudo -E apt-get install -y -q --no-install-recommends make binutils build-essential gcc g++ patch bzip2 perl cpio unzip rsync file bc wget python python-dev xxd libncurses5-dev cvs git mercurial rsync liblscp-dev subversion python3 python3-dev python3-distutils python3-setuptools ca-certificates openssh-client expect locales sudo procps | |
sudo -E apt-get -y autoremove | |
sudo -E apt-get -y clean | |
sudo rm -rf /var/lib/apt/lists/* | |
sudo sed -i 's/# \(en_US.UTF-8\)/\1/' /etc/locale.gen | |
sudo locale-gen --purge --lang en_US.UTF-8 | |
- name: Combine Disks(合并磁盘) | |
uses: easimon/maximize-build-space@master | |
with: | |
swap-size-mb: 1024 | |
temp-reserve-mb: 100 | |
root-reserve-mb: 1024 | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Clone Source Code(克隆源代码) | |
run: | | |
df -hT $GITHUB_WORKSPACE | |
git clone $REPO_URL -b master | |
cd FunBin-OS | |
echo "OPENWRT_PATH=$PWD" >> $GITHUB_ENV | |
VERSION_INFO=$(git show -s --date=short --format="作者: %an<br/>时间: %cd<br/>内容: %s<br/>hash: %H") | |
echo "VERSION_INFO=$VERSION_INFO" >> $GITHUB_ENV | |
- name: Generate Variables(生成变量) | |
run: | | |
cd $OPENWRT_PATH | |
SOURCE_REPO="$(echo $REPO_URL | awk -F '/' '{print $(NF)}')" | |
echo "SOURCE_REPO=$SOURCE_REPO" >> $GITHUB_ENV | |
DEVICE_TARGET=$(cat FunBin/configs/funbin_defconfig | grep BR2_LINUX_KERNEL_INTREE_DTS_NAME | awk -F '"' '{print $2}') | |
echo "DEVICE_TARGET=$DEVICE_TARGET" >> $GITHUB_ENV | |
- name: Build SDK | |
run: | | |
cd $OPENWRT_PATH | |
make sdk | |
- name: Compile Firmware(开始编译固件) | |
id: compile | |
run: | | |
cd $OPENWRT_PATH | |
echo -e "$(nproc) thread compile" | |
make -j$(nproc) || make -j1 || make -j1 V=s | |
echo "status=success" >> $GITHUB_OUTPUT | |
echo "DATE=$(date +"%Y-%m-%d %H:%M:%S")" >> $GITHUB_ENV | |
echo "FILE_DATE=$(date +"%Y.%m.%d")" >> $GITHUB_ENV | |
- name: Check Space Usage(检查空间使用情况) | |
if: (!cancelled()) | |
run: df -hT | |
- name: Upload Bin Directory(上传固件) | |
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true' | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ env.SOURCE_REPO }}-bin-${{ env.DEVICE_TARGET }}-${{ env.FILE_DATE }} | |
path: ${{ env.OPENWRT_PATH }}/images | |
- name: Organize Files(整理文件) | |
if: steps.compile.outputs.status == 'success' | |
run: | | |
cd $OPENWRT_PATH | |
rm -rf SDK/output/ | |
rm -rf FunBin/output/ | |
touch br.log | |
cp br.log images/ -rf | |
tar -jcf - download | split -b 2000m - download.tar.bz2 | |
cp download.tar.bz* images/ -rf | |
cd images | |
echo "FIRMWARE_PATH=$PWD" >> $GITHUB_ENV | |
- name: Upload Firmware To Artifact(将固件上传到Artifact) | |
if: steps.compile.outputs.status == 'success' | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ env.SOURCE_REPO }}-firmware-${{ env.DEVICE_TARGET }}-${{ env.FILE_DATE }} | |
path: ${{ env.FIRMWARE_PATH }} | |
- name: Upload Firmware To Release(发布固件) | |
if: steps.compile.outputs.status == 'success' | |
uses: ncipollo/release-action@v1 | |
with: | |
name: FunBoy-${{ env.DATE }} | |
allowUpdates: true | |
tag: ${{ env.FIRMWARE_TAG }}-${{ env.FILE_DATE }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: ${{ env.FIRMWARE_PATH }}/* | |
body: | | |
**This is FunKey-OS Image out** | |
- ⚽ 固件源码: ${{ env.REPO_URL }} | |
- 💝 设备名称: ${{ env.DEVICE_TARGET }} | |
### 🧊 固件版本 | |
- 固件编译前最后一次➦[主源码](${{ env.REPO_URL }})更新记录 | |
- ${{ env.VERSION_INFO }} |