Skip to content

Build Arm64.mini OpenWrt v22.03.6 #19

Build Arm64.mini OpenWrt v22.03.6

Build Arm64.mini OpenWrt v22.03.6 #19

#
# Copyright (c) 2019-2020 P3TERX <https://p3terx.com>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
# https://github.com/P3TERX/Actions-OpenWrt
# Description: Build OpenWrt using GitHub Actions
#
name: Build Arm64.mini OpenWrt v22.03.6
permissions: write-all
#开启写权限,防止无法上传到release
on:
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
schedule:
- cron: '0 18 * * 5'
env:
REPO_URL: https://github.com/openwrt/openwrt
REPO_BRANCH: v22.03.6
FEEDS_CONF: feeds.conf.default.none
CONFIG_FILE: OpenWRT/v22.arm64.mini.config
CUSTOM_SH: OpenWRT/custom.sh
UPLOAD_BIN_DIR: false
UPLOAD_FIRMWARE: true
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
FILE_NAME: OP2203_ARM_ROOTFS_mini
PRODUCT_NAME: OP2203_ARM_ROOTFS_mini
GITHUB_RELEASE: https://github.com/518512/My-ROOTFS
DISTRIB_REVISION: OpenWRT 22.03.6
KERNEL_PATCHVER: 无内核,纯LXC ROOTFS
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc "/usr/local/share/boost" "$AGENT_TOOLSDIRECTORY"
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: 缓存加速
uses: stupidloud/cachewrtbuild@main
if: env.CACHE_BUILD == 'true' || (github.event.inputs.CACHE_BUILD == 'true')
with:
ccache: 'true'
prefix: ${{ github.workspace }}/openwrt
- name: 更新时区、编译时间
id: date
run: |
sudo timedatectl set-timezone "$TZ"
echo "FILE_TIME=$(date +"%m-%d %H.%M")" >> $GITHUB_ENV
echo "FILE_TIME1=$(date "+%Y年%m月%d日-%H点%M分")" >> $GITHUB_ENV
echo "FILE_TIME2=$(date "+%Y%m%d-%H%M")" >> $GITHUB_ENV
echo "编译开始时间..."
START_TIME=`date +'%Y-%m-%d %H:%M:%S'`
echo "START_SECONDS=$(date --date="$START_TIME" +%s)" >> $GITHUB_ENV
- name: Clone source code
working-directory: /workdir
run: |
df -hT $PWD
git clone $REPO_URL -b $REPO_BRANCH openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
echo "DATE=$(date "+%Y-%m-%d %H")" >> $GITHUB_ENV
echo "DATE1=$(date "+%Y-%m-%d")" >> $GITHUB_ENV
- name: Update feeds
run: cd openwrt && ./scripts/feeds update -a
- name: Install feeds
run: cd openwrt && ./scripts/feeds install -a
- name: Load custom configuration
run: |
[ -e files ] && mv files openwrt/files
[ -e banner ] && mv banner openwrt/package/base-files/files/etc/banner
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
cat openwrt/.config # 确认 .config 文件内容
chmod +x $CUSTOM_SH
cd openwrt
$GITHUB_WORKSPACE/$CUSTOM_SH
- name: SSH connection to Actions
uses: P3TERX/[email protected]
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
env:
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
- name: Download package
id: package
run: |
cd openwrt
make defconfig
cat .config # 输出配置文件内容
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: Compile the firmware
id: compile
run: |
cd openwrt
echo -e "$(nproc) thread compile"
make -j$(nproc) || make -j1 || make -j1 V=s
echo "status=success" >> $GITHUB_OUTPUT
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME
[ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
echo "编译完成时间..."
START_SECONDS=${{ env.START_SECONDS }}
END_TIME=`date +'%Y-%m-%d %H:%M:%S'`
END_SECONDS=$(date --date="$END_TIME" +%s)
SECONDS=$((END_SECONDS-START_SECONDS))
HOUR=$(( $SECONDS/3600 )) && MIN=$(( ($SECONDS-${HOUR}*3600)/60 )) && SEC=$(( $SECONDS-${HOUR}*3600-${MIN}*60 ))
echo "BUILD_TIME=${HOUR}时${MIN}分${SEC}秒" >> $GITHUB_ENV
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
echo "FILE_DATE2=$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
- name: Check space usage
if: (!cancelled())
run: df -hT
- name: Upload bin directory
uses: actions/upload-artifact@main
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'
with:
name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: openwrt/bin
- name: Organize files
id: organize
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled()
run: |
cd openwrt/bin/targets/*/*
rm -rf packages
rm -rf *.buildinfo
rm -rf *.manifest
rm -rf sha256sums
rm -rf *.bin
rm -rf openwrt-armvirt-64-Image
rm -rf openwrt-armvirt-64-Image-initramfs
rm -rf openwrt-armvirt-64-rootfs-ext4.img.gz
rm -rf openwrt-armvirt-64-rootfs-squashfs.img.gz
rm -rf openwrt-armvirt-64-rootfs.cpio.gz
mv openwrt-armvirt-64-default-rootfs.tar.gz openwrt-22.03${{ env.VERSION }}-armsr-armv8-generic-rootfs-${{ env.FILE_DATE2 }}.tar.gz
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload firmware directory
uses: actions/upload-artifact@master
if: steps.organize.outputs.status == 'success' && !cancelled()
with:
name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: ${{ env.FIRMWARE }}
#- name: Generate release tag
#id: tag
#if: env.UPLOAD_RELEASE == 'true' && !cancelled()
#run: |
## echo "::set-output name=release_tag::$(date +"%Y.%m.%d-%H%M")"
#echo "release_tag=${{ env.FILE_NAME }}" >> $GITHUB_OUTPUT
#touch release.txt
#[ $UPLOAD_COWTRANSFER = true ] && echo "🔗 [Cowtransfer](${{ steps.cowtransfer.outputs.url }})" >> release.txt
#[ $UPLOAD_WETRANSFER = true ] && echo "🔗 [WeTransfer](${{ steps.wetransfer.outputs.url }})" >> release.txt
## echo "::set-output name=status::success"
#echo "status=success" >> $GITHUB_OUTPUT
- name: Create release
id: release
uses: ncipollo/release-action@v1
with:
name: R${{ env.DATE }} for ${{ env.PRODUCT_NAME }}
allowUpdates: true
tag: ${{ env.FILE_NAME }} # 确保 tag 名称有效,去除非法字符和空格
commit: ${{ github.sha }} # 使用有效的 commit SHA 值
token: ${{ secrets.TOKEN3 }}
body: |
**OpenWRT official Mini Firmware for Armvirt/Armsr 64**
### 📒 固件信息
- 🚀 每日:OpenWRT 作者固件 ➦ [xYx-c](https://github.com/xYx-c/build-openwrt/releases) ➦ [Zane-E](https://github.com/Zane-E/ROOTFS/releases) ➦ [217heidai](https://github.com/217heidai/OpenWrt-Builder/releases)
- 🚀 随缘:LXC MINI ROOTFS ➦ [OpenWRT](https://github.com/518512/xYx-openwrt/releases) ➦ [LEDE](https://github.com/518512/ROOTFS/releases) ➦ [ImmortalWrt](https://github.com/518512/ROOTFS/releases)即可下载
- 💻 平台架构: Armvirt/Armsr 64 , 🌐 默认地址: 10.5.2.1 , 🔑 默认密码: password
- ⚽ 固件源码: ${{ env.REPO_URL }} , 💝 源码分支: ${{ env.REPO_BRANCH }}(22.03.6)
### 🧊 固件版本
- LXC Mini底包,非完整固件,每周五18点自动编译
- 固件编译前最后一次➦[主源码](${{ env.REPO_URL }})更新记录
${{ env.useVersionInfo }}
artifacts: ${{ env.FIRMWARE }}/*
#- name: Upload firmware to release
# uses: softprops/action-gh-release@v1
# if: steps.tag.outputs.status == 'success' && !cancelled()
# env:
# GITHUB_TOKEN: ${{ secrets.TOKEN3 }}
# with:
# tag_name: ${{ steps.tag.outputs.release_tag }}
# body_path: release.txt
# files: ${{ env.FIRMWARE }}/*
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ secrets.TOKEN3 }}
repository: ${{ github.repository }}
retain_days: 3
keep_minimum_runs: 3
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@master
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
repo:
keep_latest: 10
delete_tag_pattern:
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.TOKEN3 }}
- name: Telegram notification
run: |
curl "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" -d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}&text=
您的${{ env.PRODUCT_NAME }}固件成功编译完成了!
🛠 编译版本:${{ env.DISTRIB_REVISION }}
🖥 内核版本:${{ env.KERNEL_PATCHVER }}
🎈 编译时间:${{ env.FILE_TIME1 }}
⏰ 编译用时:${{ env.BUILD_TIME }}
🎉 发布地址:${{ env.GITHUB_RELEASE }}
🌴 固件已经编译完成 🎈!!!
" >/dev/null 2>&1 && echo "ok..."